ssh 免密登录配置后还是无效
配置ssh登录
[hadoop@bigdata1~]$ mkdir .ssh
[hadoop@bigdata1~]$ ssh-keygen -t rsa //执行命令一路回车,生成秘钥
[hadoop@bigdata1~]$cd .ssh
[hadoop@bigdata1.ssh]$ ls
id_rsa id_rsa.pub
[hadoop@bigdata1.ssh]$ cat id_rsa.pub >> authorized_keys //将公钥保存到authorized_keys认证文件中
[hadoop@bigdata1.ssh]$ ls
authorized_keys id_rsa id_rsa.pub
[hadoop@bigdata1.ssh]$ cd ..
[hadoop@bigdata1~]$ chmod 700 .ssh //必须需要改为此权限
[hadoop@bigdata1~]$ chmod 600 .ssh/* //必须需要改为此权限
[hadoop@bigdata1~]$ ssh bigdata1
The authenticity of host 'bigdata1(::1)' can't be established.
RSA key fingerprint is 6e:6b:0f:2a:b8:91:3f:c8:f0:39:e4:df:b4:d8:16:6b.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'bigdata1(::1)' (RSA) to the list of known hosts.
username@localhost's password:
经过上面的ssh配置按理来说应该是可以密码登录的,但是事与愿违啊,还是不行!怎么办?找了好多资料都说是 chmod 700 .ssh 和chmod 600 .ssh/* 权限修改,但是我已经修改了啊,还是不行。最后冷静下来想想,是否还有上层的权限也需要修改呢?后来发现原来hadoop用户所在的目录下权限好像和其他用户的不对(/home/hadoop):
drwx---rwx 9 hadoop hadoop 4096 Jul 31 10:16 hadoop //这里发现其他用户组的权限给大了
所以,改正hadoop用户目录的权限为 chmod 700 hadoop,然后再是试:
[hadoop@bigdata1~]$ ssh bigdata1
Last login: Mon Jul 31 10:47:37 2017 from bigdata1
解决了,惊喜不?意外不?刺激不?