Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions completions/ssh-keygen
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ _comp_cmd_ssh_keygen()
_comp_initialize -n := -- "$@" || return

local IFS=$' \t\n' # for ${words[*]}
local noargopts='!(-*|*[ aCIJjMNPSVWzbEFRDwfGKsTmnOrtY]*)'
local noargopts='!(-*|*[ aCIJjMNPSVWzbEFRDwfGKsTmnOrtYZ]*)'
# shellcheck disable=SC2254
case $prev in
-${noargopts}[aCIJjMNPSVWz])
-${noargopts}[aCIJjNPSVWz])
return
;;
-${noargopts}b)
Expand Down Expand Up @@ -46,6 +46,10 @@ _comp_cmd_ssh_keygen()
_comp_compgen_filedir
return
;;
-${noargopts}M)
_comp_compgen -- -W 'generate screen'
return
;;
-${noargopts}m)
_comp_compgen -- -W 'PEM PKCS8 RFC4716'
return
Expand Down Expand Up @@ -141,15 +145,23 @@ _comp_cmd_ssh_keygen()
local pathcmd protocols
pathcmd=$(type -P -- "$1") && local PATH=${pathcmd%/*}:$PATH
_comp_compgen -v protocols -x ssh query protocol-version
local types='dsa ecdsa ecdsa-sk ed25519 ed25519-sk rsa'
local -a types=(
dsa ecdsa ecdsa-sk ed25519 ed25519-sk rsa
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should remove dsa? OpenSSH removed support completely in April 2025

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe. I suppose we could also drop support for protocol version 1 which is long gone as well, but the difference is that supported protocol versions are queryable, key types are not. Anyway I won't include either in this PR.

rsa-sha2-256 rsa-sha2-512 ssh-rsa
)
if [[ ${protocols[*]} == *1* ]]; then
types+=' rsa1'
types+=(rsa1)
fi
_comp_compgen -- -W "$types"
_comp_compgen -- -W '"${types[@]}"'
return
;;
-${noargopts}Y)
_comp_compgen -- -W 'find-principals check-novalidate sign verify'
_comp_compgen -- -W \
'find-principals match-principals check-novalidate sign verify'
return
;;
-${noargopts}Z)
_comp_compgen -x ssh query ciphers
return
;;
esac
Expand Down