配置Linux 免密碼登陸
1 生成秘鑰對,一路回車就好2 修改公鑰名稱為authorized_keys3 修改權限為6004 修改sshd配置文件5 重啟sshd服務配置Linux 免密碼登陸
友情提示:
如果需要實現xshell 等終端工具實現免密碼登陸的,在生成密鑰對的時候,務必先把id_rsa就拷貝出來,不然到時候你配置好了的時候,通過xftp等工具拷貝文件出來,發現本地沒有密鑰文件,到時候就是死循環了。切記切記!!
1 生成秘鑰對,一路回車就好
[root@localhost ~]# ssh-keygen Generating public/private rsa key pair.Enter file in which to save the key (/root/.ssh/id_rsa): Created directory '/root/.ssh'.Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa.Your public key has been saved in /root/.ssh/id_rsa.pub.The key fingerprint is:92:98:a4:6d:a3:bf:04:67:f5:5f:d9:e2:9f:e1:b8:c1 [email protected] key's randomart image is:+--[ RSA 2048]----+| || || . . || + + o o || o O o S + . || * . . . + . || . . . E . || o = o || o. o.+ |+-----------------+[root@localhost ~]#
2 修改公鑰名稱為authorized_keys
[root@localhost .ssh]# cd /root/.ssh/[root@localhost .ssh]# cat id_rsa.pub >authorized_keys
3 修改權限為600
[root@localhost .ssh]# chmod 600 authorized_keys
4 修改sshd配置文件
[root@localhost .ssh]# vi /etc/ssh/sshd_config RSAAuthentication yesPubkeyAuthentication yesAuthorizedKeysFile .ssh/authorized_keysPasswordAuthentication no
5 重啟sshd服務
[root@localhost .ssh]# service sshd restartStopping sshd: [ OK ]Starting sshd: [ OK ][root@localhost .ssh]#
最後拷貝is_rsa 到任意地方保存即可實行無密碼登陸本文出自 “9462880” 博客,請務必保留此出處http://9472880.blog.51cto.com/9462880/1771312