Linux下SSH免密码登录

Linux大全评论431 views阅读模式

搭建Hadoop集群的时候一定会用到的就是SSH免密码登录

  1. [hadoop@hadoop1 ~]$ ssh-keygen -t rsa  
  2. Generating public/private rsa key pair.  
  3. Enter file in which to save the key (/home/hadoop/.ssh/id_rsa):   
  4. Enter passphrase (empty for no passphrase):   
  5. Enter same passphrase again:   
  6. Your identification has been saved in /home/hadoop/.ssh/id_rsa.  
  7. Your public key has been saved in /home/hadoop/.ssh/id_rsa.pub.  
  8. The key fingerprint is:  
  9. 26:96:da:89:60:3d:90:75:43:bf:eb:56:d1:52:d9:68 hadoop@hadoop1  
  10. The key's randomart image is:  
  11. +--[ RSA 2048]----+  
  12. |    ..+      +   |  
  13. |   o . o    E .  |  
  14. |  o     .  +     |  
  15. |   o   . .o .    |  
  16. |  o o + S  o     |  
  17. | . . * + ..      |  
  18. |    o o ..       |  
  19. |       ..        |  
  20. |       ..        |  
  21. +-----------------+  
  22. [hadoop@hadoop1 ~]$ cd .ssh  
  23. [hadoop@hadoop1 .ssh]$ scp -r id_rsa.pub hadoop@hadoop3:/home/hadoop/.ssh/authorized_keys  
  24. The authenticity of host 'hadoop3 (192.168.127.120)' can't be established.  
  25. RSA key fingerprint is 03:be:af:08:19:27:6d:15:7e:dd:90:fa:09:b3:14:2f.  
  26. Are you sure you want to continue connecting (yes/no)? yes  
  27. Warning: Permanently added 'hadoop3,192.168.127.120' (RSA) to the list of known hosts.  
  28. hadoop@hadoop3's password:   
  29. id_rsa.pub                                                       100%  396     0.4KB/s   00:00      
  30. [hadoop@hadoop1 .ssh]$ ssh hadoop3  
  31. Last login: Sat Aug  4 17:35:22 2012 from hadoop1  

如果不能没有成功

  1. [hadoop@hadoop3 ~]$ chmod 700 .ssh/  
  2. [hadoop@hadoop3 ~]$ cd .ssh  
  3. [hadoop@hadoop3 .ssh]$ chmod 600 authorized_keys   
  1. [root@hadoop3 .ssh]# vi /etc/ssh/sshd_config   
  2. AuthorizedKeysFile      .ssh/authorized_keys  把前面的#号去掉  
  3. [root@hadoop3 .ssh]# /etc/rc.d/init.d/sshd restart  
  4. Stopping sshd:                                             [  OK  ]  
  5. Starting sshd:                                             [  OK  ]  

企鹅博客
  • 本文由 发表于 2020年6月14日 00:53:25
  • 转载请务必保留本文链接:https://www.qieseo.com/154046.html

发表评论