linux 免登陆设置

免登陆 (进入到虚拟机,以root方式登陆)
vi /etc/ssh/sshd_config

(要确保这些字符前无注释符号“#”)

RSAAuthentication yes

PubkeyAuthentication yes

AuthorizedKeysFile .ssh/authorized_keys

PasswordAuthentication yes

PeimitEmptyPasswords yes


执行
ssh-agent bash
ssh-keygen -t rsa
ssh-add /root/.ssh/id_rsa
进入到 cd /root/.ssh/
touch /root/.ssh/authorized
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
service sshd restart
实现了自己的免登陆(有时候得在真正的主机上执行这些命令,远程的不行)

在node1中存在node3的秘钥,node3可以登陆node1.删除了node3的秘钥,就不能登陆了
也就是node3中存在node1的密码,node1中不逊在node3的,则不能登陆(将node1的公钥加入到各个节点上)
另外要注意请务必要将服务器上
~/.ssh权限设置为700
~/.ssh/authorized_keys的权限设置为600

chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

这是linux的安全要求,如果权限不对,自动登录将不会生效
ssh-keygen -t rsa
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
ssh root@node1 cat ~/.ssh/id_rsa.pub>> authorized_keys
service sshd restart

scp id_rsa.pub root@192.168.1.153:/hhr
cat id_rsa.pub >> ~/.ssh/authorized_keys

posted on 2016-06-23 23:01  wonder2636  阅读(346)  评论(0编辑  收藏  举报

导航