Skip to content

Commit

Permalink
ssh: don't offer protocol v1 specific options if it's not supported
Browse files Browse the repository at this point in the history
  • Loading branch information
scop committed Apr 20, 2019
1 parent d2bec62 commit aba5560
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions completions/ssh
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,12 @@ _ssh_macs()

_ssh_options()
{
compopt -o nospace
COMPREPLY=( $(compgen -S = -W 'AddKeysToAgent AddressFamily BatchMode
BindAddress CanonicalDomains CanonicalizeFallbackLocal
CanonicalizeHostname CanonicalizeMaxDots CanonicalizePermittedCNAMEs
CertificateFile ChallengeResponseAuthentication CheckHostIP Cipher
Ciphers ClearAllForwardings Compression CompressionLevel
ConnectionAttempts ConnectTimeout ControlMaster ControlPath
local opts=(
AddKeysToAgent AddressFamily BatchMode BindAddress CanonicalDomains
CanonicalizeFallbackLocal CanonicalizeHostname CanonicalizeMaxDots
CanonicalizePermittedCNAMEs CertificateFile
ChallengeResponseAuthentication CheckHostIP Ciphers ClearAllForwardings
Compression ConnectionAttempts ConnectTimeout ControlMaster ControlPath
ControlPersist DynamicForward EnableSSHKeysign EscapeChar
ExitOnForwardFailure FingerprintHash ForwardAgent ForwardX11
ForwardX11Timeout ForwardX11Trusted GatewayPorts GlobalKnownHostsFile
Expand All @@ -50,15 +49,21 @@ _ssh_options()
LocalCommand LocalForward LogLevel MACs
NoHostAuthenticationForLocalhost NumberOfPasswordPrompts
PasswordAuthentication PermitLocalCommand PKCS11Provider Port
PreferredAuthentications Protocol ProxyCommand ProxyJump ProxyUseFdpass
PreferredAuthentications ProxyCommand ProxyJump ProxyUseFdpass
PubkeyAcceptedKeyTypes PubkeyAuthentication RekeyLimit RemoteCommand
RemoteForward RequestTTY RevokedHostKeys RhostsRSAAuthentication
RSAAuthentication SendEnv ServerAliveCountMax ServerAliveInterval
SmartcardDevice StreamLocalBindMask StreamLocalBindUnlink
StrictHostKeyChecking SyslogFacility TCPKeepAlive Tunnel TunnelDevice
UpdateHostKeys UsePrivilegedPort User UserKnownHostsFile
VerifyHostKeyDNS VisualHostKey XAuthLocation' \
-- "$cur") )
RemoteForward RequestTTY RevokedHostKeys SendEnv ServerAliveCountMax
ServerAliveInterval SmartcardDevice StreamLocalBindMask
StreamLocalBindUnlink StrictHostKeyChecking SyslogFacility TCPKeepAlive
Tunnel TunnelDevice UpdateHostKeys UsePrivilegedPort User
UserKnownHostsFile VerifyHostKeyDNS VisualHostKey XAuthLocation )
local protocols=$(_ssh_query "$1" protocol-version)
if [[ -z $protocols || $protocols == *1* ]]; then
opts+=( Cipher CompressionLevel Protocol RhostsRSAAuthentication
RSAAuthentication )
fi

compopt -o nospace
COMPREPLY=( $(compgen -S = -W '${opts[@]}' -- "$cur" ) )
}

# Complete a ssh suboption (like ForwardAgent=y<tab>)
Expand Down Expand Up @@ -245,7 +250,7 @@ _ssh()
return
;;
-*o)
_ssh_options
_ssh_options "$1"
return
;;
-*Q)
Expand Down

0 comments on commit aba5560

Please sign in to comment.