说明:默认已经安装有ssh服务场景:A、B两台主机,A主机免密登陆B主机
步骤如下:
A主机生成密钥
ssh-keygen -t rsa -P ''
- 将公钥添加到B机
authorized_keys权限为600
scp .ssh/id_rsa.pub user@host:~/.ssh/authorized_keys
或者
scp .ssh/id_rsa.pub user@host:~/.ssh/id_rsa.pub.a
cat id_rsa.pub.a>>authorized_keys
设置权限
chmod 600 authorized_keys
免密登陆
ssh user@host
添加主机
vim /etc/hosts