本文介绍了具有2个不同.pem密钥的2个服务器之间的scp命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用scp和2个不同的.pem密钥将文件夹从服务器A传输到服务器B。
I want to transfer a folder from server A to server B with scp and 2 different .pem keys.
这是解决问题的最佳方法,并且会真正起作用吗。
Is this the best way to go about it and will this actually work.
scp -i ~/Documents/server1.pem -r root@server1.com:~/location/to/dir -i ~/Documents/server2.pem ~/location/to/copy/to
还是我必须输入:
scp -i ~/Documents/server1.pem -r root@server1.com:~/location/to/dir -i ~/Documents/server2.pem root@server2.com:~/location/to/copy/to
我不确定第二个位置是否需要输入主机或只是位置。
非常感谢您的帮助。
I am just not sure with the second location if I need to input the host or just the location.Many thanks for your help.
推荐答案
创建一个配置文件,例如〜/ scp_config
:
Create a config file like ~/scp_config
:
Host src
HostName server1.com
User root
CertificateFile %d/Documents/server1.pem
Host dest
HostName server2.com
User root
CertificateFile %d/Documents/server2.pem
然后运行
scp -3 -F ~/scp_config src:\~/location/to/dir dest:\~/location/to/copy/to
这篇关于具有2个不同.pem密钥的2个服务器之间的scp命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!