vi .ssh/config 添加
Host * ServerAliveInterval 180 ControlPersist yes ControlMaster auto ControlPersist 8h ControlPath ~/.ssh/.sessions/%C Host */* ControlMaster auto ControlPersist yes ControlPersist 8h ControlPath ~/.ssh/.sessions/%%C ProxyCommand ssh -l %r -p %p -W %h:%p
Host mon Hostname ip User root Port 22
利用sshpass自动输入密码 vi .zshrc
alias sshp='sshpass -p password ssh -p 22 -l root' 或者把密码写环境变量里export SSHPASS=password alias sshp='sshpass -e ssh -p 22 -l root'