Issue
I am connecting from a UNIX server to a third party server (EFT on client side). EFT supports only dual authentication.
So client has provided us the userid and password and we have shared the public key to them.
My shell script has to push and pull the files from third party.
I don't have expect
, lftp
, curl
, sshpass
in my server, cannot install then either.
How do I pass the password for the sftp
command in the shell script to connect to remote server?
Now I am keying the password manually for the file transfer to happen, which is working.
But need to automate this.
Please advise.
Solution
If you really need a password authentication (in addition to the public key authentication), you cannot use vanilla OpenSSH ssh
. It is purposefully built in a way not to allow automating password authentication.
- Either you need to hack the password input for
ssh
using tools likeexpect
andsshpass
:
Automatically enter SSH password with script
How to run the sftp command with a password from Bash script?
(it seems that you know this); - Or use another SFTP client (it seems that you have none and you cannot install any);
- That basically leaves you with implementing something. Either you will have to implement
expect
/sshpass
equivalent. Or use your favourite programing language that is available on your server to implement the SFTP: Python/Perl/Ruby/PHP/C/C++. There are SFTP libraries for all of them.
Answered By - Martin Prikryl Answer Checked By - Willingham (WPSolving Volunteer)