当我通过 ssh 连接到远程系统并执行 scp 时,我没有收到密码提示:
# ssh 192.168.1.32 "scp joe\@192.168.1.31:/etc/hosts /tmp"
Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,password,keyboard-interactive).
如果我像这样分解它,它就可以正常工作:
# ssh 192.168.1.32
# scp joe\@192.168.1.31:/etc/hosts /tmp
[email protected]'s password:
在上述第一个例子中,我怎样才能让它提示我输入密码?
注意:不,我不能对此使用基于密钥的身份验证。
答案1
尝试一下-t
。来自 ssh 手册页:
-t Force pseudo-tty allocation. This can be used to execute arbi‐
trary screen-based programs on a remote machine, which can be
very useful, e.g. when implementing menu services. Multiple -t
options force tty allocation, even if ssh has no local tty.
可能发生的情况是,scp 尝试从 tty 读取,但因为没有 tty 而失败。