ssh指令定制及自动补全

1.利用Git的git-bash来做ssh的交互终端
不再使用git-bash进行交互了,统一使用msys2工具包进行管理。它可以实现linux的子系统。
注:参考这文章http://www.kxtry.com/archives/2334
2.在git-bash终端中执行【vim .bashrc】,添加以下指令

complete -W "$(echo $(grep '^Host ' F:/tools/myssh/config  | sort -u | sed 's/^Host //'))" remote
complete -W "$(echo $(grep '^Host ' F:/tools/myssh/config  | sort -u | sed 's/^Host //'))" xscp

3.编辑ssh的config文件

Host logkaf67
    HostName 10.0.0.67
    Port 22
    User heguowen
    IdentityFile c:\tools\ssh\id_rsa
    ProxyJump jumpServer   #since ssh 7.3 supports.
    #ProxyCommand ssh abc@10.2.16.210 nc %h %p

4.编辑remote脚本

#!/bin/sh

path_current=`pwd`
path_script=$(cd "$(dirname "$0")"; pwd)
cfg=$path_script/config

if [ $# -lt 0 ]; then
   awk '{if($1 == "Host"){print $2}}' $cfg
else
   ssh -F $cfg $*
fi

5.编辑xscp脚本

#!/bin/sh

path_current=`pwd`
path_script=$(cd "$(dirname "$0")"; pwd)
cfg=$path_script/config
if [ $# -lt 1 ]; then
   awk '{if($1 == "Host"){print $2}}' $cfg
else
   scp -F $cfg $*
fi