Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Ohmyzsh
Commits
4a69ee57
Unverified
Commit
4a69ee57
authored
Aug 26, 2021
by
Marc Cornellà
Browse files
feat(ssh-agent): allow specifying absolute path to `identities`
Fixes #9650
parent
0c590aba
Changes
2
Hide whitespace changes
Inline
Side-by-side
plugins/ssh-agent/README.md
View file @
4a69ee57
...
@@ -27,6 +27,15 @@ To **load multiple identities** use the `identities` style, For example:
...
@@ -27,6 +27,15 @@ To **load multiple identities** use the `identities` style, For example:
zstyle :omz:plugins:ssh-agent identities id_rsa id_rsa2 id_github
zstyle :omz:plugins:ssh-agent identities id_rsa id_rsa2 id_github
```
```
**NOTE:**
the identities may be an absolute path if they are somewhere other than
`~/.ssh`
. For example:
```
zsh
zstyle :omz:plugins:ssh-agent identities ~/.config/ssh/id_rsa ~/.config/ssh/id_rsa2 ~/.config/ssh/id_github
# which can be simplified to
zstyle :omz:plugins:ssh-agent identities ~/.config/ssh/
{
id_rsa,id_rsa2,id_github
}
```
----
----
To
**set the maximum lifetime of the identities**
, use the
`lifetime`
style.
To
**set the maximum lifetime of the identities**
, use the
`lifetime`
style.
...
...
plugins/ssh-agent/ssh-agent.plugin.zsh
View file @
4a69ee57
...
@@ -23,12 +23,12 @@ function _start_agent() {
...
@@ -23,12 +23,12 @@ function _start_agent() {
}
}
function
_add_identities
()
{
function
_add_identities
()
{
local id
line sig lines
local id
file
line sig lines
local
-a
identities loaded_sigs loaded_ids not_loaded
local
-a
identities loaded_sigs loaded_ids not_loaded
zstyle
-a
:omz:plugins:ssh-agent identities identities
zstyle
-a
:omz:plugins:ssh-agent identities identities
# check for .ssh folder presence
# check for .ssh folder presence
if
[[
!
-d
$HOME
/.ssh
]]
;
then
if
[[
!
-d
"
$HOME
/.ssh
"
]]
;
then
return
return
fi
fi
...
@@ -52,10 +52,12 @@ function _add_identities() {
...
@@ -52,10 +52,12 @@ function _add_identities() {
# add identities if not already loaded
# add identities if not already loaded
for
id
in
$identities
;
do
for
id
in
$identities
;
do
# if id is an absolute path, make file equal to id
[[
"
$id
"
=
/
*
]]
&&
file
=
"
$id
"
||
file
=
"
$HOME
/.ssh/
$id
"
# check for filename match, otherwise try for signature match
# check for filename match, otherwise try for signature match
if
[[
${
loaded_ids
[(I)
$
HOME
/.ssh/
$id
]
}
-le
0
]]
;
then
if
[[
${
loaded_ids
[(I)
$
file
]
}
-le
0
]]
;
then
sig
=
"
$(
ssh-keygen
-lf
"
$
HOME
/.ssh/
$id
"
|
awk
'{print $2}'
)
"
sig
=
"
$(
ssh-keygen
-lf
"
$
file
"
|
awk
'{print $2}'
)
"
[[
${
loaded_sigs
[(I)
$sig
]
}
-le
0
]]
&&
not_loaded+
=(
"
$
HOME
/.ssh/
$id
"
)
[[
${
loaded_sigs
[(I)
$sig
]
}
-le
0
]]
&&
not_loaded+
=(
"
$
file
"
)
fi
fi
done
done
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment