centos配置ssh免密碼登入後,仍提示輸入密碼

來源:互聯網
上載者:User

標籤:

配置SSH無密碼登入需要3步:

    1.產生公開金鑰和私密金鑰

    2.匯入公開金鑰到認證檔案,更改許可權

    3.測試

 

1.產生公開金鑰和私密金鑰Shell代碼  
  1. ssh-keygen -t dsa -P ‘‘ -f ~/.ssh/id_dsa

  
   預設在 ~/.ssh目錄產生兩個檔案:
    id_rsa      :私密金鑰
    id_rsa.pub  :公開金鑰

2.匯入公開金鑰到認證檔案    2.1 匯入本機Shell代碼  
  1. cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys  


 

    2.2 匯入要免密碼登入的伺服器

        首先將認證檔案複製到伺服器

Shell代碼  
  1. scp ~/.ssh/authorized_keys [email protected]主機名稱:/home/xxx/.ssh/

 

 一般以上幾步就ok了,但我的仍要輸入密碼,

用root使用者登陸查看系統的記錄檔:$tail /var/log/secure -n 20

…………

Oct  7 10:26:43 MasterServer sshd[2734]: Authentication refused: bad ownership or modes for file /home/hadooper/.ssh/authorized_keys
Oct  7 10:26:48 MasterServer sshd[2734]: Accepted password for hadooper from ::1 port 37456 ssh2
Oct  7 10:26:48 MasterServer sshd[2734]: pam_unix(sshd:session): session opened for user hadooper by (uid=0)
Oct  7 10:36:30 MasterServer sshd[2809]: Accepted password for hadooper from 192.168.1.241 port 36257 ssh2
Oct  7 10:36:30 MasterServer sshd[2809]: pam_unix(sshd:session): session opened for user hadooper by (uid=0)
Oct  7 10:38:28 MasterServer sshd[2857]: Authentication refused: bad ownership or modes for directory /home/hadooper/.ssh

…………

提示/home/hadooper/.ssh和 /home/hadooper/.ssh/authorized_keys許可權不對,修改如下:      Shell代碼  
  1. chmod 700 ~/.ssh
  2. chmod 600 ~/.ssh/authorized_keys  

   

3.測試

    ssh host,第一次登入可能需要yes確認,之後就可以直接登入了。

 

轉自: http://blog.csdn.net/hwwn2009/article/details/39852457

centos配置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.