I cannot get Restic to work initializing repository on Windows 10 host over sftp

restic init -r sftp:backup-to-laptop:/

enter password for new repository:
enter password again:
Fatal: create key in repository at sftp:backup-to-laptop:/ failed: OpenFile: sftp: “Bad message” (SSH_FX_BAD_MESSAGE)

Have you tried e.g. FileZilla to check that you can actually connect to this sftp server?

Yes, it works. In fact the init command creates lots of filesystem objects before failing.

What is exactly SFTP server? Windows? Linux? What software?

Latest OpenSSH on Windows.

Have you tried:

restic init -r sftp:/backup-to-laptop:/
restic init -r sftp:/backup-to-laptop


restic init -r sftp:backup-to-laptop/

I did the command as I wrote which is how the documentation said to do it. I am trying to init a repository in the (chroot) root of the ssh host defined by backup-to-laptop. It actually works for a while, many dirs are created. Then it fails. The only unusual thing I’m doing is the ssh host is actually remote port forwarded via an ssh tunnel so I will eliminate that from the process and try again then report back here.

I tried all of your commands and they don’t work. I also eliminated the SSH port forwarding and it still didn’t work.

You mean it creates folders?

Yes, I said objects as I did not check if it also created files…

Maybe this is the problem? It creates folders but they do not have right permissions and then can not save any files?

If I initialise the repository using windows restic then try to backup with linux restic it gives the same error, but it does it creating lock files (which are empty, I don’t know if they’re supposed to be), the lock files are created but the error is returned.

If I upload files with the sftp command under linux they are successfully created so it’s not a simple permissions problem. If it’s a more subtle one, I do not know.

One more thought. Max path limit…

In Windows I think it is 256. Now if your sftp root seats somewhere deep in the local path adding file like “01b60bb5cfb077414121cf4d63f9cd9cf7251e39a8d051fff31eadb4f3dad4cc” might be too much…

Short files names over FileZilla would work but not long ones like restic is using.

It’s 1 folder deep (not including repo itself) with a short name. I wondered about the path limit too, but it’s creating files, it creates lots of lock files.

You could try rclone serve sftp instead of OpenSSH as Windows sftp server.

I used rclone REST server tunnelled over SSH and it works flawlessly, thank you for this suggestion.

1 Like