Backup to sftp with login/password


thanks for this nice project. I need to make some backup to an sftp location, from windows machines. I can connect to with login/password from (works OK with filezilla, git/sftp or putty/psftp).
But, i hadn’t seen it at first glance, this won’t work with restic which doesn’t expect that identification. For a test, seeing that psftp has a -pw parameter, I naively tried with it:

restic.exe -r -o sftp.command “psftp -pw password -b ./putty.script” init
putty.script being “cd to/my/destination”, it doesn’t support path AFAIK.

I fails with unknown command “psftp -pw password -b ./putty.script” for “restic”

So first, could could you confirm the normal syntax for passing “sftp.command”? it’s not clear in my humble mind!

I would be happy moving to public/private keys, but, unfortunately users who may use restic don’t have a home folder on server, only an sftp access (ssh is disallowed). Is it feasable nonetheless? another path for access_keys could be configured by admin, but I don’t know if it’s the solution.

Any info would be great,
Thanks a lot!
Best regards

psftp is designed as an interactive tool and if I didn’t miss any documentation on it, it doesn’t support any parameters. You probably should use plink.

Try something like this:
sftp.command="path/to/plink.exe -s -l user -P 22 -pw secretpassword host sftp"

Note that I haven’t tried this myself. I simply adjusted fd0’s example from this Github topic.

Hey, welcome to the forum! Thanks for @764287 for helping out, that’d exactly be my answer. On Linux, password-based login is supported with using the default ssh client, that hasn’t been implemented on Windows yet.

You seem to have a different issue though, restic complains that it can’t find the program you’re passing in with -o sftp.command=[...]. restic expects that this is a command which establishes some connection and then speaks sftp on stdin/stdout. On Linux/Unix this would be something along the lines of ssh user@host -s sftp, where -s sftp requests that the remote SSH server starts an sftp server.

Thank you very much for your answers.
I don’t know putty’s suite a lot and not at all plink. I should have investigated more before crying out for help! But, psftp has a batch mode and password param:

psftp --help
PuTTY Secure File Transfer (SFTP) client
Release 0.70
Usage: psftp [options] [user@]host
   -V        print version information and exit
   -pgpfp    print PGP key fingerprints and exit
   -b file   use specified batchfile
  -pw passw login with specified password

and indeed I could connect when passing out a password (-pw password) and thought it could work. I think it’s not the recommended way, but for now, I’m planning a simple demo of restic to our team.

Anyway, I’ll give a try to your solutions on Monday.
Kind regards

@drens I’m pretty sure from the help output you pasted that psftp is the wrong tool. It seems to be an sftp client, but what restic needs is a program that only establishes a connection to the sftp server, and then let’s restic speak sftp. That’s what plink does, at least other users reported that it works.


just to confirm that the plink solution indeed works.
Thanks a lot.