- 打开MacOS的终端,默认进入当前用户目录,进入.ssh目录,创建一个config文件。
touch config
- 在config文件中配置需要远程连接的服务器信息。
vim config
Host server1
User root
Hostname 192.168.1.100
Port 22
ServerAliveInterval 60
ServerAliveCountMax 60
- 配置完成后就可以通过ssh server1登录设备了,输入密码即可,不用每次都输入用户名,端口和主机名了。后面两个参数是为了保持连接用的,否则空闲就会超时断开。
$ ssh server1
root@192.168.1.100's password: