Jenkins進階系列之——09配置Linux系統ssh免密碼登陸

來源:互聯網
上載者:User

標籤:pen   get   login   步驟   root   www   oct   htm   which   

ssh認證的完整描述:https://www.ibm.com/developerworks/cn/linux/security/openssh/part1/

說明:點我去查看

今天我們只說產生ssh的key,從而達到免密碼登陸的目的。

不知道ssh是什麼的自己看說明。好了,不廢話了。

系統:CentOS 5.8

  1. 確認使用者

     確認目前使用者是你需要的使用者!

    $ whoamifroad    #froad使用者,根據你自己的需求選擇使用者。我這兒用froad使用者示範。

     

  2. 產生key
    $ cd ~ #回到使用者目錄,不回去也沒有關係$ ssh-keygen     #可以使用-t選項選擇加密方式,包括 RSA 和 DSA 兩種密鑰#例如:$ssh-keygen -t dsa 或者ssh-keygen -t rsa#加密方式不同,key的名稱不同,其他沒有區別#如果沒有指定密鑰,預設RSAGenerating public/private rsa key pair.Enter file in which to save the key (/home/froad/.ssh/id_rsa): #私密金鑰存放的位置,預設會存放在使用者目錄的.ssh檔案夾,直接斷行符號Enter passphrase (empty for no passphrase): #預設,斷行符號Enter same passphrase again: #預設,斷行符號Your identification has been saved in /home/froad/.ssh/id_rsa.#私密金鑰路徑Your public key has been saved in /home/froad/.ssh/id_rsa.pub.#公開金鑰路徑The key fingerprint is:e8:b6:e6:xxxxxxxxxxxxxxxxx:ec:b5:d8 [email protected]$ cat id_***.pub >> authorized_keys    #***代表加密方式,將公開金鑰拷貝到authorized_keys檔案中。如果你有很多的電腦需要配置,將所有的id_***.pub公開金鑰拷貝到一個authorized_keys檔案中即可
  3. 配置

     將authorized_keys檔案拷貝到需要被管理的電腦上。注意:放在使用者目錄下.ssh檔案夾中。Linux使用者會限制你的存取權限

     

  4.  驗證

  5. $ ssh [email protected]#root是使用者名稱,可以根據你的需求改變The authenticity of host ‘192.168.2.xxx (192.168.2.xxx)‘ can‘t be established.RSA key fingerprint is ff:07:49:4d:xxxxxxxxxxe:2c:38.Are you sure you want to continue connecting (yes/no)? yes#同意將指紋添加到本地Warning: Permanently added ‘192.168.2.xxx‘ (RSA) to the list of known hosts.Last login: Wed Oct 23 13:58:32 2013 from 192.168.1.xxx

     只能在你產生key的電腦上訪問authorized_keys的電腦,如果你想兩台電腦互相訪問均免密碼。那麼你還需要重複上面的步驟(機器的配置剛好相反)。

     

  6. 其他

   如果添加指紋的時候提示添加失敗,是因為你以前添加過了這個ip的指紋。

   解決辦法:將.ssh目錄的known_hosts檔案刪除掉(好粗暴啊( ⊙ o ⊙ )啊!),也可以開啟這個檔案把對於ip的那條記錄刪除(這個就精細多了O(∩_∩)O哈哈~)

   如果操作步驟都正確,但是依然要求輸入密碼。一般是因為許可權的問題。命令如下

chmod 644 ~/.ssh/authorized_keys

 

Jenkins進階系列之——09配置Linux系統ssh免密碼登陸

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.