diff --git a/completions/ssh-keygen b/completions/ssh-keygen index 38013cff3af..cacde0aea7e 100644 --- a/completions/ssh-keygen +++ b/completions/ssh-keygen @@ -68,6 +68,9 @@ _comp_cmd_ssh_keygen() generator= ) ;; + *\ -*r\ *) + opts=(hashalg=) + ;; *\ -*s\ *) opts=( clear critical: extension: force-command= @@ -84,6 +87,9 @@ _comp_cmd_ssh_keygen() resident user= verify-required write-attestation= ) ;; + *\ -*Y\ *) + opts=(hashalg= print-pubkey verify-time) + ;; esac ((${#opts[@]})) && _comp_compgen -- -W '"${opts[@]}"' @@ -106,6 +112,19 @@ _comp_cmd_ssh_keygen() user=*) _comp_compgen -c "${cur#*=}" -- -u ;; + hashalg=*) + local -a args=() + case ${words[*]} in + *\ -*Y\ *) + args=(sha256 sha512) + ;; + *\ -*r\ *) + args=(sha1 sha256) + ;; + esac + ((${#args[@]})) && + _comp_compgen -c "${cur#*=}" -- -W '"${args[@]}"' + ;; esac fi return diff --git a/test/t/test_ssh_keygen.py b/test/t/test_ssh_keygen.py index f153a15e502..6e9953c3576 100644 --- a/test/t/test_ssh_keygen.py +++ b/test/t/test_ssh_keygen.py @@ -89,3 +89,11 @@ def test_O_application_ssh_colon(self, completion): ) def test_O_application_nonexistent(self, completion): assert not completion + + @pytest.mark.complete("ssh-keygen -r -O ") + def test_r_O(self, completion): + assert completion + + @pytest.mark.complete("ssh-keygen -Y -O ") + def test_Y_O(self, completion): + assert completion