`

ssh_key授权

 
阅读更多
生成rsa_key , 并添加公钥到服务器
windows:
下载XSHELL,在登陆的时候可以选择用密钥登陆, 然后直接生成,保存可以得到rsa_key.pub。

linux or Mac:
1、生成SSH密钥对
ssh-keygen -t rsa
1
2、建议直接回车使用默认路径
Enter file in which to save the key (/root/.ssh/id_rsa):
1
3、输入密码短语(留空则直接回车)
Enter passphrase (empty forno passphrase):
1
4、重复密码短语
Enter same passphrase again:
1
最后会显示生成的路径
Your identification has been saved in/root/.ssh/id_rsa.
Yourpublic key has been saved in/root/.ssh/id_rsa.pub.
1
2
·添加res_key到服务器
打开刚才生成的.pub文件,复制里面内容 , 在服务器里面输入

echo "XXX(.pub里面所有的内容)" >> /root/.ssh/authorized_keys
1
·禁止密码登陆,并启动ssh_key验证
1、编辑sshd_config文件
vi /etc/ssh/sshd_config
1
2、禁用密码验证
PasswordAuthentication no
1
3、启用密钥验证
RSAAuthentication yes
PubkeyAuthentication yes
1
2
重启服务
RHEL/CentOS系统:
service sshd restart

Ubuntu系统:
service ssh restart

debian系统:
/etc/init.d/ssh restart
版权声明:欢迎转载,转载请注明出处-->http://blog.csdn.net/adzcsx2 https://blog.csdn.net/adzcsx2/article/details/61915500
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics