summaryrefslogtreecommitdiff
path: root/completions/ssh
diff options
context:
space:
mode:
Diffstat (limited to 'completions/ssh')
-rw-r--r--completions/ssh308
1 files changed, 182 insertions, 126 deletions
diff --git a/completions/ssh b/completions/ssh
index ba3d4b45..aaa10346 100644
--- a/completions/ssh
+++ b/completions/ssh
@@ -2,8 +2,9 @@
_ssh_queries()
{
- COMPREPLY+=( $( compgen -W \
- "cipher cipher-auth mac kex key protocol-version" -- "$cur" ) )
+ COMPREPLY+=( $(compgen -W \
+ "cipher cipher-auth mac kex key key-cert key-plain protocol-version" \
+ -- "$cur") )
}
_ssh_query()
@@ -13,44 +14,61 @@ _ssh_query()
_ssh_ciphers()
{
- local ciphers='$( _ssh_query "$1" cipher )'
+ local ciphers='$(_ssh_query "$1" cipher)'
[[ $ciphers ]] || ciphers="3des-cbc aes128-cbc aes192-cbc aes256-cbc
aes128-ctr aes192-ctr aes256-ctr arcfour128 arcfour256 arcfour
blowfish-cbc cast128-cbc"
- COMPREPLY+=( $( compgen -W "$ciphers" -- "$cur" ) )
+ COMPREPLY+=( $(compgen -W "$ciphers" -- "$cur") )
}
_ssh_macs()
{
- local macs='$( _ssh_query "$1" mac )'
+ local macs='$(_ssh_query "$1" mac)'
[[ $macs ]] || macs="hmac-md5 hmac-sha1 umac-64@openssh.com hmac-ripemd160
hmac-sha1-96 hmac-md5-96"
- COMPREPLY+=( $( compgen -W "$macs" -- "$cur" ) )
+ COMPREPLY+=( $(compgen -W "$macs" -- "$cur") )
}
_ssh_options()
{
- compopt -o nospace
- COMPREPLY=( $( compgen -S = -W 'AddressFamily BatchMode BindAddress
- ChallengeResponseAuthentication CheckHostIP Cipher Ciphers
- ClearAllForwardings Compression CompressionLevel ConnectionAttempts
- ConnectTimeout ControlMaster ControlPath ControlPersist DynamicForward
- EnableSSHKeysign EscapeChar ExitOnForwardFailure ForwardAgent
- ForwardX11 ForwardX11Timeout ForwardX11Trusted GatewayPorts
- GlobalKnownHostsFile GSSAPIAuthentication GSSAPIClientIdentity
- GSSAPIDelegateCredentials GSSAPIKeyExchange GSSAPIRenewalForcesRekey
- GSSAPIServerIdentity GSSAPITrustDns HashKnownHosts Host
- HostbasedAuthentication HostKeyAlgorithms HostKeyAlias HostName
- IdentityFile IdentitiesOnly IPQoS KbdInteractiveDevices KexAlgorithms
+ 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
+ GSSAPIAuthentication GSSAPIClientIdentity GSSAPIDelegateCredentials
+ GSSAPIKeyExchange GSSAPIRenewalForcesRekey GSSAPIServerIdentity
+ GSSAPITrustDns HashKnownHosts Host HostbasedAuthentication
+ HostbasedKeyTypes HostKeyAlgorithms HostKeyAlias HostName
+ IdentitiesOnly IdentityAgent IdentityFile IgnoreUnknown Include IPQoS
+ KbdInteractiveAuthentication KbdInteractiveDevices KexAlgorithms
LocalCommand LocalForward LogLevel MACs
- NoHostAuthenticationForLocalhost NumberOfPasswordPrompts ProxyJump
+ NoHostAuthenticationForLocalhost NumberOfPasswordPrompts
PasswordAuthentication PermitLocalCommand PKCS11Provider Port
- PreferredAuthentications Protocol ProxyCommand PubkeyAuthentication
- RekeyLimit RemoteForward RequestTTY RhostsRSAAuthentication
- RSAAuthentication SendEnv ServerAliveCountMax ServerAliveInterval
- SmartcardDevice StrictHostKeyChecking TCPKeepAlive Tunnel TunnelDevice
- UsePrivilegedPort User UserKnownHostsFile VerifyHostKeyDNS
- VisualHostKey XAuthLocation' -- "$cur" ) )
+ PreferredAuthentications ProxyCommand ProxyJump ProxyUseFdpass
+ PubkeyAcceptedKeyTypes PubkeyAuthentication RekeyLimit RemoteCommand
+ 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
+ local IFS=$' \t\n' reset=$(shopt -p nocasematch); shopt -s nocasematch
+ local option
+ COMPREPLY=( $(for option in "${opts[@]}"; do
+ [[ $option == "$cur"* ]] && printf '%s=\n' "$option"
+ done) )
+ $reset
}
# Complete a ssh suboption (like ForwardAgent=y<tab>)
@@ -63,61 +81,90 @@ _ssh_suboption()
# Split into subopt and subval
local prev=${1%%=*} cur=${1#*=}
- case $prev in
- BatchMode|ChallengeResponseAuthentication|CheckHostIP|\
- ClearAllForwardings|ControlPersist|Compression|EnableSSHKeysign|\
- ExitOnForwardFailure|ForwardAgent|ForwardX11|ForwardX11Trusted|\
- GatewayPorts|GSSAPIAuthentication|GSSAPIKeyExchange|\
- GSSAPIDelegateCredentials|GSSAPIRenewalForcesRekey|GSSAPITrustDns|\
- HashKnownHosts|HostbasedAuthentication|IdentitiesOnly|\
- KbdInteractiveAuthentication|KbdInteractiveDevices|\
- NoHostAuthenticationForLocalhost|PasswordAuthentication|\
- PubkeyAuthentication|RhostsRSAAuthentication|RSAAuthentication|\
- StrictHostKeyChecking|TCPKeepAlive|UsePrivilegedPort|\
- VerifyHostKeyDNS|VisualHostKey)
- COMPREPLY=( $( compgen -W 'yes no' -- "$cur" ) )
- ;;
- AddressFamily)
- COMPREPLY=( $( compgen -W 'any inet inet6' -- "$cur" ) )
- ;;
- BindAddress)
+ case ${prev,,} in
+ batchmode|canonicaldomains|canonicalizefallbacklocal|\
+ challengeresponseauthentication|checkhostip|\
+ clearallforwardings|controlpersist|compression|enablesshkeysign|\
+ exitonforwardfailure|forwardagent|forwardx11|forwardx11trusted|\
+ gatewayports|gssapiauthentication|gssapikeyexchange|\
+ gssapidelegatecredentials|gssapirenewalforcesrekey|gssapitrustdns|\
+ hashknownhosts|hostbasedauthentication|identitiesonly|\
+ kbdinteractiveauthentication|kbdinteractivedevices|\
+ nohostauthenticationforlocalhost|passwordauthentication|\
+ proxyusefdpass|pubkeyauthentication|rhostsrsaauthentication|\
+ rsaauthentication|stricthostkeychecking|streamlocalbindunlink|\
+ tcpkeepalive|useprivilegedport|verifyhostkeydns|visualhostkey)
+ COMPREPLY=( $(compgen -W 'yes no' -- "$cur") )
+ ;;
+ addkeystoagent)
+ COMPREPLY=( $(compgen -W 'yes ask confirm no' -- "$cur") )
+ ;;
+ addressfamily)
+ COMPREPLY=( $(compgen -W 'any inet inet6' -- "$cur") )
+ ;;
+ bindaddress)
_ip_addresses
;;
- Cipher)
- COMPREPLY=( $( compgen -W 'blowfish des 3des' -- "$cur" ) )
+ canonicalizehostname)
+ COMPREPLY=( $(compgen -W 'yes no always' -- "$cur") )
;;
- ProxyJump)
- _known_hosts_real -a -F "$configfile" -- "$cur"
+ *file|identityagent|include)
+ _filedir
;;
- IPQoS)
- COMPREPLY=( $( compgen -W 'af1{1..4} af2{2..3} af3{1..3} af4{1..3}
- cs{0..7} ef lowdelay throughput reliability' -- "$cur" ) )
+ cipher)
+ COMPREPLY=( $(compgen -W 'blowfish des 3des' -- "$cur") )
;;
- HostbasedKeyTypes|HostKeyAlgorithms)
- COMPREPLY=( $( compgen -W '$( _ssh_query "$2" key )' -- "$cur" ) )
+ ciphers)
+ _ssh_ciphers "$2"
;;
- KexAlgorithms)
- COMPREPLY=( $( compgen -W '$( _ssh_query "$2" kex )' -- "$cur" ) )
+ compressionlevel)
+ COMPREPLY=( $(compgen -W '{1..9}' -- "$cur") )
;;
- Protocol)
- COMPREPLY=( $( compgen -W '1 2 1,2 2,1' -- "$cur" ) )
+ fingerprinthash)
+ COMPREPLY=( $(compgen -W 'md5 sha256' -- "$cur") )
;;
- RequestTTY)
- COMPREPLY=( $( compgen -W 'no yes force auto' -- "$cur" ) )
+ ipqos)
+ COMPREPLY=( $(compgen -W 'af1{1..4} af2{2..3} af3{1..3} af4{1..3}
+ cs{0..7} ef lowdelay throughput reliability' -- "$cur") )
;;
- Tunnel)
- COMPREPLY=( $( compgen -W 'yes no point-to-point ethernet' \
- -- "$cur" ) )
+ hostbasedkeytypes|hostkeyalgorithms)
+ COMPREPLY=( $(compgen -W '$(_ssh_query "$2" key)' -- "$cur") )
;;
- PreferredAuthentications)
- COMPREPLY=( $( compgen -W 'gssapi-with-mic host-based publickey
- keyboard-interactive password' -- "$cur" ) )
+ kexalgorithms)
+ COMPREPLY=( $(compgen -W '$(_ssh_query "$2" kex)' -- "$cur") )
;;
- MACs)
+ macs)
_ssh_macs "$2"
;;
- Ciphers)
- _ssh_ciphers "$2"
+ preferredauthentications)
+ COMPREPLY=( $(compgen -W 'gssapi-with-mic host-based publickey
+ keyboard-interactive password' -- "$cur") )
+ ;;
+ protocol)
+ local protocols=( $(_ssh_query "$2" protocol-version) )
+ [[ $protocols ]] || protocols=(1 2)
+ if [[ ${#protocols[@]} -gt 1 ]]; then
+ COMPREPLY=( $(compgen -W '${protocols[@]}' -- "$cur") )
+ fi
+ ;;
+ proxyjump)
+ _known_hosts_real -a -F "$configfile" -- "$cur"
+ ;;
+ pubkeyacceptedkeytypes)
+ COMPREPLY=( $(compgen -W '$(_ssh_query "$2" key)' -- "$cur") )
+ ;;
+ requesttty)
+ COMPREPLY=( $(compgen -W 'no yes force auto' -- "$cur") )
+ ;;
+ syslogfacility)
+ COMPREPLY=( $(compgen -W 'DAEMON USER AUTH LOCAL{0..7}' -- "$cur") )
+ ;;
+ tunnel)
+ COMPREPLY=( $(compgen -W 'yes no point-to-point ethernet' \
+ -- "$cur") )
+ ;;
+ updatehostkeys)
+ COMPREPLY=( $(compgen -W 'yes no ask' -- "$cur") )
;;
esac
return 0
@@ -130,7 +177,7 @@ _ssh_suboption_check()
{
# Get prev and cur words without splitting on =
local cureq=`_get_cword :=` preveq=`_get_pword :=`
- if [[ $cureq == *=* && $preveq == -o ]]; then
+ if [[ $cureq == *=* && $preveq == -*o ]]; then
_ssh_suboption $cureq "$1"
return $?
fi
@@ -170,55 +217,58 @@ _ssh()
local ipvx
case $prev in
- -F|-i|-S)
- _filedir
- return
+ -*4*)
+ ipvx=-4
;;
- -I)
- _filedir so
+ -*6*)
+ ipvx=-6
+ ;;
+ -*b)
+ _ip_addresses
return
;;
- -c)
+ -*c)
_ssh_ciphers "$1"
return
;;
- -J)
- _known_hosts_real -a -F "$configfile" -- "$cur"
+ -*[DeLpRW])
return
;;
- -m)
- _ssh_macs "$1"
+ -*[EFiS])
+ _filedir
return
;;
- -l)
- COMPREPLY=( $( compgen -u -- "$cur" ) )
+ -*I)
+ _filedir so
return
;;
- -O)
- COMPREPLY=( $( compgen -W 'check forward exit stop' -- "$cur" ) )
+ -*J)
+ _known_hosts_real -a -F "$configfile" -- "$cur"
return
;;
- -o)
- _ssh_options
+ -*l)
+ COMPREPLY=( $(compgen -u -- "$cur") )
return
;;
- -Q)
- _ssh_queries "$1"
+ -*m)
+ _ssh_macs "$1"
return
;;
- -w)
- _available_interfaces
+ -*O)
+ COMPREPLY=( $(compgen -W 'check forward exit stop' -- "$cur") )
return
;;
- -b)
- _ip_addresses
+ -*o)
+ _ssh_options "$1"
return
;;
- -D|-e|-L|-p|-R|-W)
+ -*Q)
+ _ssh_queries "$1"
return
;;
- -4|-6)
- ipvx=$prev
+ -*w)
+ _available_interfaces
+ return
;;
esac
@@ -229,7 +279,7 @@ _ssh()
COMPREPLY=( "${COMPREPLY[@]/#/-F}" )
cur=-F$cur # Restore cur
elif [[ "$cur" == -* ]]; then
- COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) )
+ COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") )
else
_known_hosts_real $ipvx -a -F "$configfile" -- "$cur"
@@ -237,7 +287,7 @@ _ssh()
_count_args
if [[ $args -gt 1 ]]; then
compopt -o filenames
- COMPREPLY+=( $( compgen -c -- "$cur" ) )
+ COMPREPLY+=( $(compgen -c -- "$cur") )
fi
fi
} &&
@@ -258,28 +308,31 @@ _sftp()
local ipvx
case $prev in
- -b|-F|-i)
- _filedir
+ -*4*)
+ ipvx=-4
+ ;;
+ -*6*)
+ ipvx=-6
+ ;;
+ -*[BDlPRs])
return
;;
- -o)
- _ssh_options
+ -*[bFi])
+ _filedir
return
;;
- -c)
+ -*c)
_ssh_ciphers
return
;;
- -S)
- _command
+ -*o)
+ _ssh_options
return
;;
- -B|-D|-l|-P|-R|-s)
+ -*S)
+ _command
return
;;
- -4|-6)
- ipvx=$prev
- ;;
esac
if [[ "$cur" == -F* ]]; then
@@ -289,7 +342,7 @@ _sftp()
COMPREPLY=( "${COMPREPLY[@]/#/-F}" )
cur=-F$cur # Restore cur
elif [[ "$cur" == -* ]]; then
- COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) )
+ COMPREPLY=( $(compgen -W '$(_parse_usage "$1")' -- "$cur") )
else
_known_hosts_real $ipvx -a -F "$configfile" -- "$cur"
fi
@@ -312,7 +365,7 @@ _scp_remote_files()
local path=${cur#*:}
# unescape (3 backslashes to 1 for chars we escaped)
- path=$( command sed -e 's/\\\\\\\('$_scp_path_esc'\)/\\\1/g' <<<"$path" )
+ path=$(command sed -e 's/\\\\\\\('$_scp_path_esc'\)/\\\1/g' <<<"$path")
# default to home dir of specified user on remote host
if [[ -z $path ]]; then
@@ -322,16 +375,16 @@ _scp_remote_files()
local files
if [[ $1 == -d ]]; then
# escape problematic characters; remove non-dirs
- files=$( ssh -o 'Batchmode yes' $userhost \
+ files=$(ssh -o 'Batchmode yes' $userhost \
command ls -aF1dL "$path*" 2>/dev/null | \
- command sed -e 's/'$_scp_path_esc'/\\\\\\&/g' -e '/[^\/]$/d' )
+ command sed -e 's/'$_scp_path_esc'/\\\\\\&/g' -e '/[^\/]$/d')
else
# escape problematic characters; remove executables, aliases, pipes
# and sockets; add space at end of file names
- files=$( ssh -o 'Batchmode yes' $userhost \
+ files=$(ssh -o 'Batchmode yes' $userhost \
command ls -aF1dL "$path*" 2>/dev/null | \
command sed -e 's/'$_scp_path_esc'/\\\\\\&/g' -e 's/[*@|=]$//g' \
- -e 's/[^\/]$/& /g' )
+ -e 's/[^\/]$/& /g')
fi
COMPREPLY+=( $files )
}
@@ -351,10 +404,10 @@ _scp_local_files()
fi
if $dirsonly ; then
- COMPREPLY+=( $( command ls -aF1dL $cur* 2>/dev/null | \
+ COMPREPLY+=( $(command ls -aF1dL $cur* 2>/dev/null | \
command sed -e "s/$_scp_path_esc/\\\\&/g" -e '/[^\/]$/d' -e "s/^/$1/") )
else
- COMPREPLY+=( $( command ls -aF1dL $cur* 2>/dev/null | \
+ COMPREPLY+=( $(command ls -aF1dL $cur* 2>/dev/null | \
command sed -e "s/$_scp_path_esc/\\\\&/g" -e 's/[*@|=]$//g' \
-e 's/[^\/]$/& /g' -e "s/^/$1/") )
fi
@@ -378,31 +431,34 @@ _scp()
local ipvx
case $prev in
- -l|-P)
+ -*4*)
+ ipvx=-4
+ ;;
+ -*6*)
+ ipvx=-6
+ ;;
+ -*c)
+ _ssh_ciphers
+ COMPREPLY=( "${COMPREPLY[@]/%/ }" )
return
;;
- -F|-i)
+ -*[Fi])
_filedir
compopt +o nospace
return
;;
- -c)
- _ssh_ciphers
- COMPREPLY=( "${COMPREPLY[@]/%/ }" )
+ -*[lP])
return
;;
- -o)
+ -*o)
_ssh_options
return
;;
- -S)
+ -*S)
_command
compopt +o nospace
return
;;
- -4|-6)
- ipvx=$prev
- ;;
esac
_expand || return
@@ -420,8 +476,8 @@ _scp()
else
case $cur in
-*)
- COMPREPLY=( $( compgen -W '$( _parse_usage "${words[0]}" )' \
- -- "$cur" ) )
+ COMPREPLY=( $(compgen -W '$(_parse_usage "${words[0]}")' \
+ -- "$cur") )
COMPREPLY=( "${COMPREPLY[@]/%/ }" )
return
;;