mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-02-06 02:51:32 +01:00
Fix: Support all SSH private key formats in ssh-agent plugin
The previous implementation only supported OpenSSH private keys, which start with "-----BEGIN OPENSSH PRIVATE KEY-----". This commit improves the plugin to support all valid private key formats by using the 'file' command to identify them based on their content. This change ensures that the ssh-agent plugin can handle keys in various formats, including PKCS#1, PKCS#8, and OpenSSH.
This commit is contained in:
parent
b3ba8da421
commit
2f5817c258
1 changed files with 2 additions and 2 deletions
|
|
@ -44,8 +44,8 @@ function _add_identities() {
|
||||||
if [[ ${#identities[@]} -eq 0 ]]; then
|
if [[ ${#identities[@]} -eq 0 ]]; then
|
||||||
# Iterate over files in .ssh folder.
|
# Iterate over files in .ssh folder.
|
||||||
for file in "$HOME/.ssh"/*; do
|
for file in "$HOME/.ssh"/*; do
|
||||||
# Check if file is a regular file and starts with "-----BEGIN OPENSSH PRIVATE KEY-----".
|
# Check if file is a valid private key using file magic.
|
||||||
if [[ -f "$file" && $(command head -n 1 "$file") =~ ^-----BEGIN\ OPENSSH\ PRIVATE\ KEY----- ]]; then
|
if [[ -f "$file" && $(file -b "$file") == *"private key"* ]]; then
|
||||||
# Add filename (without path) to identities array.
|
# Add filename (without path) to identities array.
|
||||||
identities+=("${file##*/}")
|
identities+=("${file##*/}")
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue