Install Expect, который позволяет вам создавать сценарии для таких ситуаций.
sudo apt-get install expect
Настроить сценарий оболочки
#!/bin/bash
HOST=""
USER=""
PASS=""
# Sorry for the offensive "assword", it's to cope with "Password" and "password".
VAR=$(expect -c "
spawn sftp $USER@$HOST
expect \"assword:\"
send \"$PASS\r\"
expect \"\\\\$\"
send \"ls\r\"
expect -re \"$USER.*\"
send \"exit\"
")
echo "==============="
echo "$VAR"