CentOS配置SSH無密碼登錄需要3步:
1.生成公鑰和私鑰
ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
默認在 ~/.ssh目錄生成兩個文件:
id_rsa :私鑰
id_rsa.pub :公鑰
2.導入公鑰到認證文件
2.1 導入本機
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
2.2 導入要免密碼登錄的服務器
首先將認證文件復制到服務器
scp ~/.ssh/authorized_keys xxx@主機名:/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
…………
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
3.測試
ssh host,第一次登錄可能需要yes確認,之後就可以直接登錄了。
提高Ubuntu的SSH登陸認證速度的辦法 http://www.linuxidc.com/Linux/2014-09/106810.htm
開啟SSH服務讓Android手機遠程訪問 Ubuntu 14.04 http://www.linuxidc.com/Linux/2014-09/106809.htm
如何為Linux系統中的SSH添加雙重認證 http://www.linuxidc.com/Linux/2014-08/105998.htm
在 Linux 中為非 SSH 用戶配置 SFTP 環境 http://www.linuxidc.com/Linux/2014-08/105865.htm
Linux 上SSH 服務的配置和管理 http://www.linuxidc.com/Linux/2014-06/103627.htm
SSH入門學習基礎教程 http://www.linuxidc.com/Linux/2014-06/103008.htm
Linux 下 SSH 命令實例指南 http://www.linuxidc.com/Linux/2014-09/106910.htm
更多CentOS相關信息見CentOS 專題頁面 http://www.linuxidc.com/topicnews.aspx?tid=14