为什么scp不能从文件中生成stdin?


1

我正在尝试scppasswd使用命令调用的文件中自动输入密码

scp folder/ user@server.com:./ < passwd

但它不起作用。

我知道我们可以使用无密码SSH作为替代方案,但我正在寻找解释为什么这不起作用。


你能详细说明你的问题吗?提供的信息很少,因此很难回答,有关如何提出好问题的更多信息,请参阅如何提问
2013年

关于SO的这个Q&A处理ssh,但它应该是同样的问题scp
mpy 2013年

“scp和rsync旨在检测他们的密码输入是不是来自终端来阻止这种事情。” unix.com/shell-programming-scripting / ...
Everett

Answers:


3

我的猜测是scp使用该getpass函数来读取密码。从glibc手册

它试图连接到真正的终端,/dev/tty如果可能的话,鼓励用户不要在文件中加入明文密码; 否则,它使用stdinstderr

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.