Revert "feat(ssh-agent): add keys regardless of filename (#12741)" (#12761)
This reverts commit d2d5155d41cbe183ef172fef1e83a29d116a5af6.
Closes #12743
Closes #12745
Closes #12758
Diff
1diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh
2index becd5ea172f12b98d9b5d38833823e35cb55d7ec..83548648b7231c7a209b8dce3641822cebb1cda1 100644
3--- a/plugins/ssh-agent/ssh-agent.plugin.zsh
4+++ b/plugins/ssh-agent/ssh-agent.plugin.zsh
5@@ -39,16 +39,13 @@ function _add_identities() {
6 return
7 fi
8 9- # If no keys specified in zstyle, add default keys.
10- # Mimics calling ssh-add with no arguments.
11- if [[ ${#identities[@]} -eq 0 ]]; then
12- # Iterate over files in .ssh folder.
13- for file in "$HOME/.ssh"/*; do
14- # Check if file is a regular file and starts with "-----BEGIN OPENSSH PRIVATE KEY-----".
15- if [[ -f "$file" && $(command head -n 1 "$file") =~ ^-----BEGIN\ OPENSSH\ PRIVATE\ KEY----- ]]; then
16- # Add filename (without path) to identities array.
17- identities+=("${file##*/}")
18- fi
19+ # add default keys if no identities were set up via zstyle
20+ # this is to mimic the call to ssh-add with no identities
21+ if [[ ${#identities} -eq 0 ]]; then
22+ # key list found on `ssh-add` man page's DESCRIPTION section
23+ for id in id_rsa id_dsa id_ecdsa id_ed25519 id_ed25519_sk identity; do
24+ # check if file exists
25+ [[ -f "$HOME/.ssh/$id" ]] && identities+=($id)
26 done
27 fi
28