跳到主要内容

SSH

SSH (Secure Shell Protocol) 是 Linux 系统中常用的远程登录工具,用于在本地计算机和远程服务器之间建立安全的连接

连接复用

在使用多个终端SSH会话时,可以配置连接复用,从而避免重复输入密码进行认证,参考的配置内容如下:

~/.ssh/config
Host *
TCPKeepAlive yes # 保持连接
ServerAliveInterval 10 # 每隔10秒发送一次心跳包
ServerAliveCountMax 700 # 如果700秒内没有收到心跳包,则认为连接已断开
StrictHostKeyChecking no # 不检查主机密钥
ForwardAgent yes # 转发代理
Compression yes # 压缩
ControlPersist 48h # 保持连接48小时
ControlMaster auto # 自动管理连接
ControlPath ~/.ssh/.%u-%r@%h:%p # 连接路径