假设A服务器要把文件复制到B服务器上
首先我们要在A服务器上生成密钥对
参考:https://www.cnblogs.com/pxblog/p/14396409.html
然后在把生成的密钥公钥id_rsa.pub 复制到B服务器上的 ~/.ssh文件夹下,名称改为 authorized_keys
(如果已经存在 就追加进去 不要直接覆盖)
如果使用ssh连接的时候报错
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "/root/.ssh/id_rsa": bad permissions
这个时候执行
chmod 600 ~/.ssh/id_rsa ~/.ssh/id_rsa.pub