Update 05.04.2026
This commit is contained in:
@@ -90,7 +90,7 @@ use the `ssh-add-args` setting. You can pass multiple arguments separated by spa
|
||||
zstyle :omz:plugins:ssh-agent ssh-add-args -K -c -a /run/user/1000/ssh-auth
|
||||
```
|
||||
|
||||
These will then be passed the the `ssh-add` call as if written directly. The example
|
||||
These will then be passed the `ssh-add` call as if written directly. The example
|
||||
above will turn into:
|
||||
|
||||
```zsh
|
||||
@@ -99,6 +99,33 @@ ssh-add -K -c -a /run/user/1000/ssh-auth <identities>
|
||||
|
||||
For valid `ssh-add` arguments run `ssh-add --help` or `man ssh-add`.
|
||||
|
||||
### Powerline 10k specific settings
|
||||
|
||||
Powerline10k has an instant prompt setting that doesn't like when this plugin
|
||||
writes to the console. Consider using the following settings if you're using
|
||||
p10k (documented above):
|
||||
|
||||
```
|
||||
zstyle :omz:plugins:ssh-agent quiet yes
|
||||
zstyle :omz:plugins:ssh-agent lazy yes
|
||||
```
|
||||
|
||||
### macOS specific settings
|
||||
|
||||
macOS supports using passphrases stored in the keychain when adding identities
|
||||
to the ssh-agent.
|
||||
|
||||
```
|
||||
ssh-add --apple-use-keychain ~/.ssh/id_rsa ...
|
||||
```
|
||||
|
||||
|
||||
This plugin can be configured to use the keychain when loading using the following:
|
||||
|
||||
```
|
||||
zstyle :omz:plugins:ssh-agent ssh-add-args --apple-load-keychain
|
||||
```
|
||||
|
||||
## Credits
|
||||
|
||||
Based on code from Joseph M. Reagle: https://www.cygwin.com/ml/cygwin/2001-06/msg00537.html
|
||||
|
||||
@@ -13,6 +13,11 @@ function _start_agent() {
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ ! -d "$HOME/.ssh" ]]; then
|
||||
echo "[oh-my-zsh] ssh-agent plugin requires ~/.ssh directory"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Set a maximum lifetime for identities added to ssh-agent
|
||||
local lifetime
|
||||
zstyle -s :omz:plugins:ssh-agent lifetime lifetime
|
||||
@@ -38,7 +43,7 @@ function _add_identities() {
|
||||
# this is to mimic the call to ssh-add with no identities
|
||||
if [[ ${#identities} -eq 0 ]]; then
|
||||
# key list found on `ssh-add` man page's DESCRIPTION section
|
||||
for id in id_rsa id_dsa id_ecdsa id_ed25519 identity; do
|
||||
for id in id_rsa id_dsa id_ecdsa id_ed25519 id_ed25519_sk identity; do
|
||||
# check if file exists
|
||||
[[ -f "$HOME/.ssh/$id" ]] && identities+=($id)
|
||||
done
|
||||
@@ -57,7 +62,7 @@ function _add_identities() {
|
||||
# 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
|
||||
if [[ ${loaded_ids[(I)$file]} -le 0 ]]; then
|
||||
if [[ -f $file && ${loaded_ids[(I)$file]} -le 0 ]]; then
|
||||
sig="$(ssh-keygen -lf "$file" | awk '{print $2}')"
|
||||
[[ ${loaded_sigs[(I)$sig]} -le 0 ]] && not_loaded+=("$file")
|
||||
fi
|
||||
@@ -93,8 +98,14 @@ function _add_identities() {
|
||||
|
||||
# Add a nifty symlink for screen/tmux if agent forwarding is enabled
|
||||
if zstyle -t :omz:plugins:ssh-agent agent-forwarding \
|
||||
&& [[ -n "$SSH_AUTH_SOCK" && ! -L "$SSH_AUTH_SOCK" ]]; then
|
||||
ln -sf "$SSH_AUTH_SOCK" /tmp/ssh-agent-$USERNAME-screen
|
||||
&& [[ -n "$SSH_AUTH_SOCK" ]]; then
|
||||
if [[ ! -L "$SSH_AUTH_SOCK" ]]; then
|
||||
if [[ -n "$TERMUX_VERSION" ]]; then
|
||||
ln -sf "$SSH_AUTH_SOCK" "$PREFIX"/tmp/ssh-agent-$USERNAME-screen
|
||||
else
|
||||
ln -sf "$SSH_AUTH_SOCK" /tmp/ssh-agent-$USERNAME-screen
|
||||
fi
|
||||
fi
|
||||
else
|
||||
_start_agent
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user