码迷,mamicode.com
首页 > 系统相关 > 详细

Linux设置远程免密登录

时间:2018-06-07 21:47:12      阅读:259      评论:0      收藏:0      [点我收藏+]

标签:highlight   col   pubkey   命令   密码   roo   密钥   margin   登录   

1.生成公钥 / 私钥对

[root@localhost ~]# ssh-keygen -t rsa -P ‘‘

-P表示密码,-P ‘‘ 就表示空密码,也可以不用-P参数,这样就要三车回车,用-P就一次回车。
该命令将在用户/root/目录下面产生一个隐藏文件目录 .ssh,使用ls -a可以查看,/root/.ssh命令下面存放着一对密钥id_rsa和id_rsa.pub

 

2.创建authorized_keys文件,将id_rsa.pub内容复制到文件里面

[root@localhost ~]#  touch authorized_keys
[root@localhost ~]#  cat /root/.ssh/id_rsa.pub >> authorized_keys
[root@localhost ~]#  chmod 600 authorized_keys

 authorized_keys的权限最小要是600!!!

 

3.修改 sshd 的配置文件 /etc/ssh/sshd.conf ,取消注释

#RSAAuthentication yes
#PubkeyAuthentication yes
#AuthorizedKeysFile      .ssh/authorized_keys

 

4. 重启sshd

[root@localhost ~]#  service sshd restart

 

5 . 使用 id_rsa远程登录

 

Linux设置远程免密登录

标签:highlight   col   pubkey   命令   密码   roo   密钥   margin   登录   

原文地址:https://www.cnblogs.com/jinxiblog/p/9152739.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!