码迷,mamicode.com
首页 > 其他好文 > 详细

centos ssh免密码秘钥登录

时间:2016-05-27 07:06:06      阅读:225      评论:0      收藏:0      [点我收藏+]

标签:

假设从A主机ssh登录B主机,用秘钥代替密码,步骤如下:

 

1、在A主机上执行:ssh-keygen -t  rsa

    一切默认,不用输入密码,生成两个文件:

     /root/.ssh/id_rsa

     /root/.ssh/id_rsa.pub

 

2、生成authorized_keys文件:

touch /root/.ssh/authorized_keys

cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys

chmod 700 /root/.ssh/id_rsa

 

3、把authorized_keys文件拷贝到B主机上:

scp /root/.ssh/authorized_keys root@xx.xx.xx.xx:/root/.ssh/

如果B主机上没有/root/.ssh目录,则先登录到B主机上执行ssh-keygen -t  rsa,再拷贝authorized_keys文件。

 

4、完成

 

centos ssh免密码秘钥登录

标签:

原文地址:http://www.cnblogs.com/lavezhang/p/5533294.html

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