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

ssh配置无密码登录

时间:2017-08-23 10:41:51      阅读:128      评论:0      收藏:0      [点我收藏+]

标签:无密码登陆   scp   mod   ima   art   save   auth   nbsp   print   

1.在master机器上生成公钥:

[root@master ~]# ssh-keygen -t rsa    注:一直按enter键就可以生成了

Generating public/private rsa key pair.

Enter file in which to save the key (/root/.ssh/id_rsa): 

Created directory ‘/root/.ssh‘.

Enter passphrase (empty for no passphrase): 

Enter same passphrase again: 

Your identification has been saved in /root/.ssh/id_rsa.

Your public key has been saved in /root/.ssh/id_rsa.pub.

The key fingerprint is:

81:39:eb:23:2c:f9:75:af:93:cb:76:00:87:3e:cf:0f root@master

The key‘s randomart image is:

+--[ RSA 2048]----+

|                 |

|       o         |

|      +..        |

|      oo..       |

|     ..oS        |

|   o .o .        |

|  o o ++Eo       |

|   o o +*o.      |

|    .  .+*o      |

+-----------------+

2..执行 cp id_rsa.pub authorized_keys

3.把master上面的authorized_keys文件复制到Slave机器上

  scp authorized_keys slave:~/.ssh

4..slave1上的修改.ssh目录的权限以及authorized_keys 的权限(这个必须修改,要不然还是需要密码)

sudo chmod 644 ~/.ssh/authorized_keys
 
sudo chmod 700 ~/.ssh
5.在master上登陆:
输入ssh slave1 不需密码登陆slave1则设置成功!
 
提示:master上想无密码登陆slave1,则需把master生成的公钥放到slave1上;反之,slave1想无密码登陆master,则需要把slave1的公钥放到master上。

ssh配置无密码登录

标签:无密码登陆   scp   mod   ima   art   save   auth   nbsp   print   

原文地址:http://www.cnblogs.com/code4app/p/7415294.html

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