Operating System - HP-UX
1753951 Members
7661 Online
108811 Solutions
New Discussion юеВ

Re: Scripting sftp with password authentication

 
SOLVED
Go to solution
Carl Houseman
Super Advisor

Scripting sftp with password authentication

I'm attempting to automate an sftp process, but have been unable to provide the password that works interactively.

The remote server is not ours and we would prefer to solve this without further involving the other party if at all possible.

But every attempt I've made, reading and following various other articles in this forum, has failed. I've run it with debugging on and if -b or BatchMode Yes is given, no attempt is made to read the password from stdin or the batch file. It appears that authentication must complete before the batch file or stdin is read for commands.

Is that the final word? Is there no way to non-interactively supply a password?

This is HP-UX 11.11
SSH is " T1471AA A.04.30.002 HP-UX Secure Shell"
4 REPLIES 4
TTr
Honored Contributor

Re: Scripting sftp with password authentication

> HP-UX 11.11 SSH is " T1471AA A.04.30.002 HP-UX Secure Shell"

You did not say if this is your server or the other party's server or both.

> without further involving the other party if at all possible.

Why don't you get this working within your own environment? You have sftp and it should be easy to find an sshd specially if the above mentioned HP-UX environment is yours.
Steve Lewis
Honored Contributor
Solution

Re: Scripting sftp with password authentication

There is a way, using expect.
You have to install expect from the porting and archive centre.
The configure a simple expect script that waits for the login prompt, sends the username,
waits for the password prompt, sends the password,
then has a line at the end which says Interact.

You then create a shell script which runs sftp in batch mode with expect. I dont have an example here, but I did make it work previously.

By the way, a better method than this is to send your key into the remote .ssh directory, so that it logs in using keys and does not request a password.

As the previous post said, this doesnt always work with different ssh versions (e.g. HP-UX /windows didnt work for me so I had to use expect).

David Bellamy
Respected Contributor

Re: Scripting sftp with password authentication

Hello Carl you can use either expect or perl take a look at this link for an idea how to use both.

http://linux-bsd-central.com/index.php/content/view/26/
Carl Houseman
Super Advisor

Re: Scripting sftp with password authentication

I can't tell by looking what the other party is using for sshd.

The information about expect may be useful if they're unwilling to install our public key files. Thanks everybody.