MobaXterm setting autocomplete

autocomplete-server-names-for-ssh-and-scp

 

mkdir /etc/bash_completion.d

cat  >> /etc/bash_completion.d/ssh << EOF
_ssh() 
{
    local cur prev opts
    COMPREPLY=()
    cur="\${COMP_WORDS[COMP_CWORD]}"
    prev="\${COMP_WORDS[COMP_CWORD-1]}"
    opts=\$(grep '^Host' ~/.ssh/config ~/.ssh/config.d/* | grep -v '[?*]' | cut -d ' ' -f 2-)

    COMPREPLY=( \$(compgen -W "\$opts" -- \${cur}) )
    return 0
}
complete -F _ssh ssh
EOF

echo ". /etc/bash_completion.d/ssh" >> ~/.profile
mkdir -p ~/.ssh/config.d/
touch ~/.ssh/config.d/fake.conf

 

cat >> ~/.ssh/config << EOF
Host public
    HostName 10.238.153.33
    User team
    IdentityFile ~/.ssh/id_rsa.team

Host 10.0.0.*
    User ubuntu
    IdentityFile ~/.ssh/id_rsa.team
    ProxyCommand ssh public nc %h %p

Host cyborg-1
    HostName 10.0.0.44
    User ubuntu
    IdentityFile ~/.ssh/id_rsa.team
    ProxyCommand ssh public nc %h %p
EOF

 

posted @ 2018-02-27 18:57  lvmxh  阅读(574)  评论(0编辑  收藏  举报