It turns out my password also wasn't accepted using sshpass
on Debian 11 running openssh-server
with openssh-sftp-server.
I had a look at the logs and could verify that the server is indeed waiting for the password to be entered.
The password prompt looks like this without sshpass
:
$ sftp -oStrictHostKeyChecking=no -i ./id_rsa me@thething
Enter passphrase for key './id_rsa':
Looking at the man page of sshpass, I found this option:
-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.
Using -P
and a matching keyword solved it.
$ echo "cd Downloads" | SSHPASS=testpass sshpass -P 'passphrase' -e sftp -oStrictHostKeyChecking=no -i ./id_rsa me@thething
Connected to thething.
sftp> cd Downloads
-b -
, like this:echo 'cd /my-path' | sshpass -p my-pass sftp -oStrictHostKeyChecking=no -i ./id_rsa user@host
-b -
the command never completes execution.-
means that stdin is piped as the script file-b -
solves the problem. Because if I use the same command than yours (with-b -
) I get the same error: user@host: Permission denied (publickey,keyboard-interactive). It seems thatsftp
by default read fromstdin
. Not sure what is wrong in your case, though