如何通过ssh远程启动时从scp获取密码提示

当我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: 

我怎么能让它在上面的第一个例子中提示我input密码?

注意:不,我无法使用基于密钥的身份validation。

尝试-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, eg when implementing menu services. Multiple -t options force tty allocation, even if ssh has no local tty. 

可能发生的事情是scp正在尝试从tty中读取,并且因为没有一个而失败。