ssh免密码认证,无需密码
如果想在一台机器实现ssh无密码登录,那么,只需要登录一个账号,进入home目录,
然后运行ssh-keygen,接着cat id_rsa.pub >> authorized_keys
参考:http://ahei.info/ssh-copy-id.htm
1、本机账号root
2、服务器victor,yansiyu
一、进入本机cd /root/.ssh/
二、ssh-keygen,然后一路回车
三、将本地的公钥id_rsa.pub拷贝到服务器的/home/victor与/home/yansiyu中,同时设置下所有者为victor.victor与yansiyu.yansiyu,方便我们下一步的操作
四、用普通账号victor,yansiyu进入服务器中将公钥的内容添加到.ssh中的authorized_keys中
cd /home/victor
mkdir .ssh
chmod 700 .ssh 非常重要
cat /home/victor/id_rsa.pub >> .ssh/authorized_keys
chmod 600 authorized_keys
相同的步骤
cd /home/yansiyu
mkdir .ssh
chmod 700 .ssh 非常重要
cat /home/yansiyu/id_rsa.pub >> .ssh/authorized_keys
chmod 600 authorized_keys