I'm creating a small backup script using sshfs
:
sshfs backup_user@target_ip:/home /mnt/backup
Is there a way to include the password in this command?
Or is there another file transfer solution where the login password can be included other than FTP/SFTP?
Best Answer
-o password_stdin
do not seem to be working on all systems, for instance freeBSD. etc.You can also use
expect
Interpreter, it should work with sshfs and should do the trick.Another solution would be
sshpass
, for instance, let say your are backing up directory /var/wwwBacking up:
uploading backup file to backup server
So it will upload directory with today's backup
But still, as it was said higher, best(safe and simple) way would be to use ssh key pair
The only inconvenience would be that you have to go through the key generation process once on every server you need to pair, but it is better than keeping a password in plain text format on all servers you want to back up :),
Generating a Key Pair the Proper way
On Local server
On remote Server
Uploading Generated Public Keys to the Remote Server
Set Permissions on Remote server
Login
Enabling SSH Protocol v2
enabling public key authorization in sshd
If StrictModes is set to yes in /etc/ssh/sshd_config then