自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

如何實(shí)現(xiàn)Linux主機(jī)遠(yuǎn)程登錄ssh免密碼

系統(tǒng) Linux 系統(tǒng)運(yùn)維
本文作者公司剛上幾臺(tái)Linux,現(xiàn)在要把主機(jī)之間實(shí)現(xiàn)都能遠(yuǎn)程ssh免密碼登陸。方法很簡(jiǎn)單,使用ssh-keygen在主機(jī)A上生成private和public密鑰,將生成的public密鑰拷貝到遠(yuǎn)程機(jī)器主機(jī)B上后,就可以使用ssh命令無(wú)需密碼登錄到另外一臺(tái)機(jī)器主機(jī)B上。

  [[152756]]

【引自xxxx的博客】一、情景

  公司剛上幾臺(tái)Linux,現(xiàn)在要把主機(jī)之間實(shí)現(xiàn)都能遠(yuǎn)程ssh免密碼登陸。

  二、原理

  很簡(jiǎn)單,使用ssh-keygen在主機(jī)A上生成private和public密鑰,將生成的public密鑰拷貝到遠(yuǎn)程機(jī)器主機(jī)B上后,就可以使用ssh命令無(wú)需密碼登錄到另外一臺(tái)機(jī)器主機(jī)B上。

  三、步驟

  主機(jī)A:

  1.生成公鑰和私鑰文件id_rsa和id_rsa.pub (敲三下回車(chē)即可)。

 

  1. [root@bogon ~]# ssh-keygen -t rsa  
  2. Generating public/private rsa key pair.  
  3. Enter file in which to save the key (/root/.ssh/id_rsa):  
  4. Enter passphrase (empty for no passphrase):  
  5. Enter same passphrase again:  
  6. Your identification has been saved in /root/.ssh/id_rsa.  
  7. Your public key has been saved in /root/.ssh/id_rsa.pub.  
  8. The key fingerprint is 
  9. 67:da:0d:79:e0:d6:2b:cd:7d:22:af:51:7e:9c:75:fe root@bogon  
  10. The key's randomart image is 
  11. +--[ RSA 2048]----+  
  12. | |  
  13. | |  
  14. | . |  
  15. | . + |  
  16. | S B o . o|  
  17. | * * = o+|  
  18. | . o B +.=|  
  19. | . + +.|  
  20. | ... E|  
  21. +-----------------+ 

  2.ssh-cop-id命令會(huì)將指定的公鑰文件復(fù)制到遠(yuǎn)程計(jì)算機(jī)。

 

  1. [root@bogon ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub root@10.1.250.166  
  2. The authenticity of host '10.1.250.166 (10.1.250.166)' can't be established.  
  3. RSA key fingerprint is c8:9d:6d:92:55:77:3d:3e:af:f5:cb:18:80:5a:47:93.  
  4. Are you sure you want to continue connecting (yes/no)? yes  
  5. Warning: Permanently added '10.1.250.166' (RSA) to the list of known hosts.  
  6. reverse mapping checking getaddrinfo for bogon [10.1.250.166] failed - POSSIBLE BREAK-IN ATTEMPT!  
  7. root@10.1.250.166's password: <主機(jī)B的登陸密碼> 
  8. Now try logging into the machine, with "ssh 'root@10.1.250.166'"and check in 
  9. .ssh/authorized_keys  
  10. to make sure we haven't added extra keys that you weren't expecting. 

  3.然后ssh登陸主機(jī)B驗(yàn)證是否需要密碼。

 

  1. [root@localhost ~]# ssh 10.1.250.166  
  2. reverse mapping checking getaddrinfo for bogon [10.1.250.166] failed - POSSIBLE BREAK-IN ATTEMPT!  
  3. Last login: Wed Oct 21 10:05:39 2015 from 10.1.250.141  
  4. [root@bogon ~]# 

  4.登陸成功后,我們需要在主機(jī)B也做下以上3步,這樣就可以相互免密碼ssh登陸。(如果有多臺(tái)主機(jī),每臺(tái)主機(jī)都做下相同操作,以方便以后管理)。

  5.權(quán)限問(wèn)題

  建議用其他用戶做ssh登陸的話,調(diào)整目錄文件權(quán)限。

  設(shè)置authorized_keys權(quán)限  

  1. chmod 644 authorized_keys 

  設(shè)置.ssh目錄權(quán)限  

  1. chmod 700 -R .ssh 

  6.要保證.ssh和authorized_keys都只有用戶自己有寫(xiě)權(quán)限。否則驗(yàn)證無(wú)效。

  本文出自 “好大的刀” 博客,請(qǐng)務(wù)必保留此出處:http://53cto.blog.51cto.com/9899631/1704792

責(zé)任編輯:火鳳凰 來(lái)源: 51CTO博客
相關(guān)推薦

2023-09-13 22:54:06

2016-01-25 13:03:21

2012-09-28 10:12:55

2009-08-17 08:22:53

linuxssh遠(yuǎn)程登錄

2015-05-28 15:32:14

Linuxssh

2024-06-20 12:35:36

2024-10-28 09:38:15

2013-05-28 13:51:57

LinuxCentos

2018-07-03 10:33:51

服務(wù)器運(yùn)維Linux

2013-04-09 15:06:23

2010-05-06 09:51:15

SCO Unix主機(jī)

2017-06-22 08:58:51

Hadoopssh+IPssh+

2018-03-09 09:45:52

LinuxSSH登錄導(dǎo)語(yǔ)

2013-08-15 16:24:13

2019-10-23 04:37:56

Jschsftp服務(wù)器

2021-08-11 09:50:34

SSHLinux命令

2015-04-09 09:08:20

2023-02-21 10:07:23

2020-09-03 10:45:46

SSHLinux遠(yuǎn)程

2020-09-10 11:00:20

SSH遠(yuǎn)程Linux
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)