scp无密码及秘钥创建
程序员文章站
2022-05-28 10:46:05
...
当A机器使用scp向B机器同步文件时,可以通过创建秘钥对的形式来建立信任关系。
-
ssh-****** -t rsa
注意: 1.所有要输入的地方均可直接回车跳过 QUOTE: Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa)::#回车 略过 Enter passphrase (empty for no passphrase):#回车略过 Enter same passphrase again:#回车略过 Your identification has been saved in /home/.username /.ssh/id_rsa. Your public key has been saved in /home/.username /.ssh/id_rsa.pub. The key fingerprint is: 38:25:c1:4d:5d:d3:89:bb:46:67:bf:52:af:c3:17:0c [email protected] Generating RSA keys: Key generation complete. 2.成功后会在你选择的文件中多出两个文件id_rsa,id_rsa.pub
-
将/root/.ssh/id_rsa.pub文件复制到B服务器的/root/.ssh/下并改名为authorized_keys
-
scp -r (要复制的文件或文件夹) (目标服务器用户名)@目标服务器ip:目标地址
-r递归
下一篇: 使用jdom 解析xml字符串