mac配置ssh秘钥快捷登录linux服务器

参考:

https://www.runoob.com/w3cnote/set-ssh-login-key.html

https://blog.csdn.net/s_istvan/article/details/80960581

1.在服务器端或者mac端使用ssh-keygen生成秘钥对

# ssh-keygen 
得到两个文件 id_rsa是私钥,id_rsa.pub是公钥

2.公钥追加到服务器端

# cd ~/.ssh
# cat id_rsa.pub >> authorized_keys

3.私钥重命名存入本地

# mv id_rsa ~/.ssh/IpOrDomain.pk

4.配置服务器端ssh_config

# vim /etc/ssh/sshd_config

RSAAuthentication yes
PubkeyAuthentication yes
PermitRootLogin yes
PasswordAuthentication no

# service sshd restart

5.配置mac端快捷登录

# vim ~/.ssh/config
添加
Host alias
HostName ip
Port 22
User root
ServerAliveInterval 60
IdentityFile ~/.ssh/ip1.pk
//如果有多个
Host alias2
HostName ip2
Port 22
User root
ServerAliveInterval 60

6.登录

# ssh alias

版权声明:本文为weixin_42818402原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。