这是可行的,但是我必须手动输入密码。
sftp -oStrictHostKeyChecking=no -i ./id_rsa user@host << !
cd /path
!这不管用。命令永远不会完成执行。
export SSHPASS=pass
sshpass -e sftp -oStrictHostKeyChecking=no -i ./id_rsa user@host << !
cd /path
!也尝试过,但结果是一样的。命令永远不会完成执行。
sshpass -p pass sftp -oStrictHostKeyChecking=no -i ./id_rsa user@host << !
cd /path
!发布于 2023-02-09 17:08:41
事实证明,我的密码也没有被接受使用sshpass在Debian 11上运行openssh服务器与openssh-sftp服务器。我查看了日志,可以验证服务器确实在等待输入密码。
在没有sshpass的情况下,密码提示如下所示:
$ sftp -oStrictHostKeyChecking=no -i ./id_rsa me@thething
Enter passphrase for key './id_rsa':查看sshpass的手册页,我发现了以下选项:
-P Set the password prompt. Sshpass searched for this prompt in the program's
output to the TTY as an indication when to send the password. By default
sshpass looks for the string "assword:" (which matches both "Password:" and
"password:"). If your client's prompt does not fall under either of these,
you can override the default with this option.使用-P和匹配关键字解决了它。
$ echo "cd Downloads" | SSHPASS=testpass sshpass -P 'passphrase' -e sftp -oStrictHostKeyChecking=no -i ./id_rsa me@thething
Connected to thething.
sftp> cd Downloadshttps://unix.stackexchange.com/questions/734565
复制相似问题