ssh免密码登录的坑

来源:互联网 发布:c语言中bind函数 编辑:程序博客网 时间:2024/05/22 09:07

用ssh-keygen命令生成公钥后,会在~/.ssh下面生成2个文件:

   [root@localhost .ssh]# ll
total 32
-rw------- 1 root root 1675 Aug 11 20:13 id_rsa
-rw-r--r-- 1 root root  408 Aug 11 20:13 id_rsa.pub


cat id_rsa.pub>>authorized_keys

登录仍然提示需要密码:

[root@localhost .ssh]# ssh localhost
The authenticity of host 'localhost (127.0.0.1)' can't be established.
RSA key fingerprint is 77:26:4d:84:86:73:f5:55:b0:91:e5:d7:28:db:71:18.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'localhost' (RSA) to the list of known hosts.
root@localhost's password: 


重新给.ssh设置权限就好了。

 1. chmod 700 ~/.ssh

 2. chmod 0600 /root/.ssh/id_rsa

 3.chmod 600 ~/.ssh/authorized_keys 

 [hdfs@localhost .ssh]$ ssh localhost
Last login: Fri Aug 11 20:15:15 2017 from localhost.localdomain
[hdfs@localhost ~]$ 





原创粉丝点击