1.修改SSH长连接
修改/etc/ssh/sshd_config
ClientAliveInterval 120
ClientAliveCountMax 720
service sshd reload/restart
2.SSH免密码登录
创建目录 mkdir -p ~/.ssh
生成公钥/密钥对 ssh-keygen -t rsa
上传公钥到远程主机 ssh-copy-id -i id_rsa.pub root@124.221.144.175
在 远程主机中/etc/ssh/sshd_config中修改
PermitRootLogin yes 允许root用户
PubkeyAuthentication yes 运行密钥登录
AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2 包含密钥文件
3.SSH登录别名
在 ~/.ssh中创建文件config
touch config
添加如下内容
Host f2
port 22
user zxia323
hostname fosstatsprd02.its.auckland.ac.nz