a本机, b远程服务器.
在a生成公钥:
ssh-keygen -t rsa
生成后用scp指令把 .ssh/id_rsa.pub 复制到远程服务器:
scp .ssh/id_rsa.pub serverip:/root/
连接到远程服务器b:
将id_rsa.pub 添加到.ssh/authorized_keys :
cat id_rsa.pub >> .ssh/authorized_keys
更改权限:
chmod 600 .ssh/authorized_keys
配置完毕。本机a可以免密码访问服务器b。