67581c53c6458566e174620361e84b364b9034d2
- Author
- Zikoeng Xi <i@zikoengxi.com>
- Committer
- GitHub <noreply@github.com>
- Date
Message
fix(ssh-agent): add identity only if identity exists (#12371)
Diff
1diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh
2index 77c422ce124e258afa45fdc7829011831c11ce0e..1da54d4ddf8393e2794ededed7498036324693c6 100644
3--- a/plugins/ssh-agent/ssh-agent.plugin.zsh
4+++ b/plugins/ssh-agent/ssh-agent.plugin.zsh
5@@ -62,7 +62,7 @@ function _add_identities() {
6 # if id is an absolute path, make file equal to id
7 [[ "$id" = /* ]] && file="$id" || file="$HOME/.ssh/$id"
8 # check for filename match, otherwise try for signature match
9- if [[ ${loaded_ids[(I)$file]} -le 0 ]]; then
10+ if [[ -f $file && ${loaded_ids[(I)$file]} -le 0 ]]; then
11 sig="$(ssh-keygen -lf "$file" | awk '{print $2}')"
12 [[ ${loaded_sigs[(I)$sig]} -le 0 ]] && not_loaded+=("$file")
13 fi