ssh免密码登录两种方法

方法一:

yum -y install openssh-clients
ssh-keygen -t rsa
cd ~/.ssh
ssh-copy-id -i ~/.ssh/id_rsa.pub 192.168.4.237
ssh-copy-id -i ~/.ssh/id_rsa.pub 192.168.4.239
ssh-copy-id -i ~/.ssh/id_rsa.pub 192.168.4.240
ssh-copy-id -i ~/.ssh/id_rsa.pub 192.168.4.241
ssh-copy-id -i ~/.ssh/id_rsa.pub 192.168.4.242

方法二:

ssh-keygen -t rsa
cat /root/.ssh/id_rsa.pub >> /root/authorized_keys
#在192.168.4.237上
scp -p ~/.ssh/id_rsa.pub root@192.168.4.239:/root/.ssh/authorized_keys
scp -p ~/.ssh/id_rsa.pub root@192.168.4.240:/root/.ssh/authorized_keys
scp -p ~/.ssh/id_rsa.pub root@192.168.4.241:/root/.ssh/authorized_keys
scp -p ~/.ssh/id_rsa.pub root@192.168.4.242:/root/.ssh/authorized_keys
#在192.168.4.239上
scp -p ~/.ssh/id_rsa.pub root@192.168.4.237:/root/.ssh/authorized_keys
scp -p ~/.ssh/id_rsa.pub root@192.168.4.240:/root/.ssh/authorized_keys
scp -p ~/.ssh/id_rsa.pub root@192.168.4.241:/root/.ssh/authorized_keys
scp -p ~/.ssh/id_rsa.pub root@192.168.4.242:/root/.ssh/authorized_keys
#在192.168.4.240上
scp -p ~/.ssh/id_rsa.pub root@192.168.4.237:/root/.ssh/authorized_keys
scp -p ~/.ssh/id_rsa.pub root@192.168.4.239:/root/.ssh/authorized_keys
scp -p ~/.ssh/id_rsa.pub root@192.168.4.241:/root/.ssh/authorized_keys
scp -p ~/.ssh/id_rsa.pub root@192.168.4.242:/root/.ssh/authorized_keys
#在192.168.4.241上
scp -p ~/.ssh/id_rsa.pub root@192.168.4.237:/root/.ssh/authorized_keys
scp -p ~/.ssh/id_rsa.pub root@192.168.4.239:/root/.ssh/authorized_keys
scp -p ~/.ssh/id_rsa.pub root@192.168.4.240:/root/.ssh/authorized_keys
scp -p ~/.ssh/id_rsa.pub root@192.168.4.242:/root/.ssh/authorized_keys
#在192.168.4.242上
scp -p ~/.ssh/id_rsa.pub root@192.168.4.237:/root/.ssh/authorized_keys
scp -p ~/.ssh/id_rsa.pub root@192.168.4.239:/root/.ssh/authorized_keys
scp -p ~/.ssh/id_rsa.pub root@192.168.4.240:/root/.ssh/authorized_keys
scp -p ~/.ssh/id_rsa.pub root@192.168.4.241:/root/.ssh/authorized_keys