如何在一行中使用用户名和密码执行scp命令

时间:2012-11-19 10:32:35

标签: terminal command scp

我想在终端

中运行scp时将密码放在一行

scp user1@xxx.xxx.x.5:sys_config /var/www/dev/

2 个答案:

答案 0 :(得分:26)

感谢您的反馈让我开始工作我使用了sshpass工具。

sshpass -p 'password' scp user1@xxx.xxx.x.5:sys_config /var/www/dev/

答案 1 :(得分:-5)

使用sshpass效果最佳。 要在scp中包含您的密码,请使用'':

scp user1:'password'@xxx.xxx.x.5:sys_config /var/www/dev/