歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux綜合 >> 學習Linux >> CentOS下SSH無密碼登錄的配置,centosssh密碼登錄

CentOS下SSH無密碼登錄的配置,centosssh密碼登錄

日期:2017/3/3 18:09:36   编辑:學習Linux

CentOS下SSH無密碼登錄的配置,centosssh密碼登錄

CentOS下SSH無密碼登錄的配置,centosssh密碼登錄


1、確認本機sshd的配置文件(需要root權限)   $ gedit /etc/ssh/sshd_config   找到以下內容,並去掉注釋符”#“   RSAAuthentication yes   PubkeyAuthentication yes   AuthorizedKeysFile .ssh/authorized_keys   2、如果修改了配置文件需要重啟sshd服務 (需要root權限)   $ /sbin/service sshd restart 配置SSH無密碼登錄需要3步: 1.生成公鑰和私鑰 2.導入公鑰到認證文件,更改權限 3.測試 1.生成公鑰和私鑰 Shell代碼: ssh-keygen -t rsa 默認在 ~/.ssh目錄生成兩個文件: id_rsa :私鑰 id_rsa.pub :公鑰 2.導入公鑰到認證文件,更改權限 2.1 導入本機 Shell代碼: cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys 2.2 導入要免密碼登錄的服務器 首先將公鑰復制到服務器 Shell代碼: scp ~/.ssh/id_rsa.pub xxx@host:/home/id_rsa.pub 然後,將公鑰導入到認證文件(這一步的操作在服務器上進行) Shell代碼: cat /home/id_rsa.pub >> ~/.ssh/authorized_keys 2.3 在服務器上更改權限 Shell代碼: chmod 700 ~/.ssh chmod 600 ~/.ssh/authorized_keys 3.測試 ssh xxx

http://xxxxxx/Linuxjc/1168792.html TechArticle

Copyright © Linux教程網 All Rights Reserved