1.改配置文件
vim ~/.ssh/config
添加如下内容
Host *
KeepAlive yes
ServerAliveInterval 60
ControlMaster auto
ControlPersist yes
ControlPath ~/.ssh/socks/%h-%p-%r
ControlPersist 10m 连接保持10分钟
ControlPersist 24h 连接保持24小时
配置成功后,首次连接需要输入密码,打开新的窗口连接相同的服务器就不再需要输入密码了
2.直接ssh -o参数加五个-o
ssh -o KeepAlive=yes ......