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 ~/.ssh directory on the remote machine must be writable only by you: rwx------ and rwxr-xr-x are fine, but rwxrwx--- is no good, even if you are the only user in your group (if you prefer numeric modes: 700 or 755, not 775).
  • Your private key file (on the local machine) must be readable and writable only by you: rw-------, i.e. 600.
  • Your ~/.ssh/authorized_keys file (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).

转载于:https://www.cnblogs.com/zaric/p/3407090.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值