non-interactively upload file to sftp server, using password

Posted by matt on Super User See other posts from Super User or by matt
Published on 2011-01-06T08:48:55Z Indexed on 2011/01/06 8:55 UTC
Read the original article Hit count: 287

Filed under:
|

Hello Guys, I know, this is not the recommended way to do this. But, I do not have another choice:

I've got to set up a cron job that will regularly upload a file to an external SFTP Server (no FTP available, and I do only have a username/password for it but no key.)

Still, I need to set up a cron that will regularly connect to that sftp and upload a file.

sftp <<EOF
put filename
exit
EOF

therefore will not work, because sftp asks for the password, before STDIN is evaluated.

What can I do, to pass the Password to sftp?

Again: I am aware of the potential security risk, but I really do not have any choice here, and the server from which the file is uploaded is protected rather well.

© Super User or respective owner

Related posts about bash

Related posts about sftp