d2d5155d41cbe183ef172fef1e83a29d116a5af6
- Author
- Щанников Михаил <79425045+mikhailde@users.noreply.github.com>
- Committer
- GitHub <noreply@github.com>
- Date
Message
Diff
1diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh
2index 83548648b7231c7a209b8dce3641822cebb1cda1..becd5ea172f12b98d9b5d38833823e35cb55d7ec 100644
3--- a/plugins/ssh-agent/ssh-agent.plugin.zsh
4+++ b/plugins/ssh-agent/ssh-agent.plugin.zsh
5@@ -39,13 +39,16 @@ function _add_identities() {
6 return
7 fi
8
9- # add default keys if no identities were set up via zstyle
10- # this is to mimic the call to ssh-add with no identities
11- if [[ ${#identities} -eq 0 ]]; then
12- # key list found on `ssh-add` man page's DESCRIPTION section
13- for id in id_rsa id_dsa id_ecdsa id_ed25519 id_ed25519_sk identity; do
14- # check if file exists
15- [[ -f "$HOME/.ssh/$id" ]] && identities+=($id)
16+ # If no keys specified in zstyle, add default keys.
17+ # Mimics calling ssh-add with no arguments.
18+ if [[ ${#identities[@]} -eq 0 ]]; then
19+ # Iterate over files in .ssh folder.
20+ for file in "$HOME/.ssh"/*; do
21+ # Check if file is a regular file and starts with "-----BEGIN OPENSSH PRIVATE KEY-----".
22+ if [[ -f "$file" && $(command head -n 1 "$file") =~ ^-----BEGIN\ OPENSSH\ PRIVATE\ KEY----- ]]; then
23+ # Add filename (without path) to identities array.
24+ identities+=("${file##*/}")
25+ fi
26 done
27 fi
28