Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SFTP asking for other user's password

Status
Not open for further replies.

tekpr00

IS-IT--Management
Jan 22, 2008
186
CA
Hello I have a file inbound.sh
who am i
oracle
ls
-rwxr-xr-x 1 oacle dba 1159 Mar 12:23 inbound.sh

here is the contents
#! /bin/sh

#SFT to external directory
/bin/sftp externalserver.com <<EOF
user john johnpaswd
get newfile
quit
EOF
exit

However this script inbound.sh when executed ask me for password as folow:
Connecting to externalserver.com
oracle@externalserver.com's password:

How would I get this script to use user john as it is inside the script.

Thanks
 
You can't do this using ssh in a raw state. There are two alternatives
[ol]
[li]Use public/private key pairs - this negates the needs for passwords - including the risks of having passwords in clear text in scripts! Google "ssh keys" for many sites which will help[/li]
[li]Use 'expect' - this is a useful utiliy for resolving this type of scripting dilemma. Google "expect software" to useful sites.[/li]
[/ol]

On the internet no one knows you're a dog

Columb Healy
 
Hi

My [tt]man sftp[/tt] says nothing about command [tt]user[/tt].

And thinking logically, SFTP uses secure connection, so it authenticates like SSH, not like FTP. So change it to this :
Code:
/bin/sftp [red]john@[/red]externalserver.com <<EOF
get newfile
quit
EOF
And of course set up key-based authentication to avoid the password prompt.

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top