Quantcast
Channel: linuxadmin: Expanding Linux SysAdmin knowledge
Viewing all articles
Browse latest Browse all 17854

Script SFTP without key-based auth

$
0
0

Yo dudes.

Ran into an interesting issue today. Couldn't use key-based auth on a remote server that only allows SFTP (so no SSH, no SCP, no keys, etc).

I had to script it, so I did a bit o' learnin about the tool sshpass.

I'm using it with the -f option so I have a plaintext password sitting in a file in a secure directory, then a cron kicks this off...

sshpass -f /path/to/file sftp -oBatchMode=no -b - user@host << ! put file1 put file2 put file3 ... ! 

This worked really well for me. There are other ways to do this (like with expect) but I found this way to work really well and be super simple.

You can also export SSHPASS then use it with the -e flag if you don't want to use a file.

submitted by chucky_z
[link][comment]

Viewing all articles
Browse latest Browse all 17854

Trending Articles