ssh免密登录

ssh免密登录

1、先在主机A上创建密钥对
ssh-keygen -t rsa
这时可以在主机A上看到生成的秘钥~/.ssh/id_rsa 和公钥 ~/.ssh/ id_rsa.pub

2、把主机A的公钥放在主机B上
scp -r /root/.ssh/id_rsa.pub 192.168.31.147:/root/.ssh/authorized_keys

hcwei