0
我必须从一台服务器移动文件到其他服务器,我使用shell脚本来自动scp命令
scp [email protected]:sourcefilepath [email protected]:destdirectory
当我执行这个脚本它要求的源和目标的密码这。这个scp命令是否可以包含在shell脚本中,以便动态选取密码?与文件名和文件路径一起?
我必须从一台服务器移动文件到其他服务器,我使用shell脚本来自动scp命令
scp [email protected]:sourcefilepath [email protected]:destdirectory
当我执行这个脚本它要求的源和目标的密码这。这个scp命令是否可以包含在shell脚本中,以便动态选取密码?与文件名和文件路径一起?
您可以通过为两台服务器生成私钥/公钥来解决此问题。
稍后使用ssh-keygen
和ssh-copy-id
将您的公钥复制到两台服务器。
步骤:
ssh-keygen
ssh-copy-id [email protected]
ssh-copy-id [email protected]
scp -3 [email protected]:sourcefilepath [email protected]:destdirectory
通知的-3
选项,这将sourceservername将文件传输到本地服务器,然后再到destservername。这样你将只有一对私钥/公钥。
嗨@krzyk - 你能告诉我确切的顺序和eact命令吗? –
[无密码SSH](http://www.linuxproblem.org/art_9.html)可以帮助你在这里。 –