html tool

2016年4月21日星期四

ssh 无密码登录

参考:http://blog.csdn.net/leexide/article/details/17252369

1、用ssh-keygen创建公钥

(1)在服务器1上执行下面的命令:
[root@Server1 ~]# ssh-keygen -t rsa 
    输入后,会提示创建.ssh/id_rsa、id_rsa.pub的文件,其中第一个为密钥,第二个为公钥。过程中会要求输入密码,为了ssh访问过程无须密码,可以直接回车 。
(2)补充说明:
ssh-keygen:生成秘钥
其中:
  -t指定算法
  -f 指定生成秘钥路径
  -N 指定密码

2、查看钥匙

[plain] view plain copy
 print?在CODE上查看代码片派生到我的代码片
  1. [root@Server1 ~]# ls -l .ssh  
  2. 总用量 8  
  3. -rw-------. 1 root root 1675 12月 10 22:20 id_rsa  
  4. -rw-r--r--. 1 root root 394 12月 10 22:20 id_rsa.pub  
   可以发现 ssh目录下的两枚钥匙。

3.将公钥复制到被管理机器

到Server2和Server3目录下执行下面的命令
[plain] view plain copy
 print?在CODE上查看代码片派生到我的代码片
  1. #cat id_dsa.pub >> ~/.ssh/authorized_keys 

没有评论:

发表评论