ssh 无密码互通
节点n1 n2 n3 互通
第一步:n1->n2互通
admin@n1 > ssh-keygen -d
admin@n1 > scp id_dsa.pub n2:~/.ssh/authorized_keys
这样就实现了 ssh n2 无密码登录
下面的同理:将本机生成的.pub文件追加到对方的authorized_keys文件里面就可以了。
这里出现过一个问题。n1->n2 正常,n2->n1同样的步骤就是不行,admin@n2 > ssh n1 总是需要密码。怎么回事?时间的问题?修改时间同样不行。
最后找出是 .ssh 权限的问题。
Make sure the permissions on the ~/.ssh directory and its contents are proper. When I first set up my ssh key auth, I didn't have the ~/.ssh folder properly set up, and it yelled at me.
- Your home directory
~and your~/.sshdirectory on the remote machine must be writable only by you:rwx------andrwxr-xr-xare fine, butrwxrwx---is no good, even if you are the only user in your group (if you prefer numeric modes:700or755, not775). - Your private key file (on the local machine) must be readable and writable only by you:
rw-------, i.e.600. - Your
~/.ssh/authorized_keysfile (on the remote machine) must be readable (at least 400), but you'll need it to be also writable (600) if you will add any more keys to it. - Also, if SELinux is set to enforcing, you may need to run
restorecon -R -v ~/.ssh(see e.g. Ubuntu bug 965663 and Debian bug #658675; this is patched in CentOS 6).

浙公网安备 33010602011771号