Revert "feat(ssh-agent): add keys regardless of filename (#12741)"

This reverts commit d2d5155d41.
This commit is contained in:
Carlo Sala 2024-10-15 12:58:31 +02:00
commit b456e7c49c
No known key found for this signature in database
GPG key ID: DA6FB450C1A4FE9A

View file

@ -39,16 +39,13 @@ function _add_identities() {
return return
fi fi
# If no keys specified in zstyle, add default keys. # add default keys if no identities were set up via zstyle
# Mimics calling ssh-add with no arguments. # this is to mimic the call to ssh-add with no identities
if [[ ${#identities[@]} -eq 0 ]]; then if [[ ${#identities} -eq 0 ]]; then
# Iterate over files in .ssh folder. # key list found on `ssh-add` man page's DESCRIPTION section
for file in "$HOME/.ssh"/*; do for id in id_rsa id_dsa id_ecdsa id_ed25519 id_ed25519_sk identity; do
# Check if file is a regular file and starts with "-----BEGIN OPENSSH PRIVATE KEY-----". # check if file exists
if [[ -f "$file" && $(command head -n 1 "$file") =~ ^-----BEGIN\ OPENSSH\ PRIVATE\ KEY----- ]]; then [[ -f "$HOME/.ssh/$id" ]] && identities+=($id)
# Add filename (without path) to identities array.
identities+=("${file##*/}")
fi
done done
fi fi