Shell script to transfer file via SFTP

Hi all,

I'm trying to do a script to transfer file between my server and an external server via SFTP protocol. It doesn't use rsa key, but password.

When I run the script, it throw back a prompt that request me to put the password. How should I do for automatic login? Pleaes help :frowning:

Thanks you in advance

#!/usr/bin/sh
user=cmsusr
pass=cmspwd
ip=10.xxx.xxx.xxx
log_file = ./pom_log
sftp -oport=40 $user@$ip << EOF >> $log_file
quote ${pass}
bye
EOF

Try searching the forums. There are several answers that you can use.

You should not be trying to inject plaintext passwords into sftp. That it's so difficult to do is actually a subtle hint, writ in mile-high flashing neon letters, that it's a really, really bad idea. Retrievably-stored passwords are almost impossible to keep safe. "Interactive password authentication" means "Password typed by a human being in realtime authentication" and no artificial substitutes for humans are acceptable. It insists on it being input to a terminal.

Use ssh keys, that's what they're there for.