Need help with restic sftp access on debian

I would appreciate any help I can get on this. Thanks in advance!

I have spent an entire day trying to understand what is going wrong.

(Sorry for the length, but I wanted to make sure I provided all the information.)

Problem:

Today Restic cannot connect with sftp. It has been working fine for the last six months. The backup this morning 1am worked fine. (Date 6/12)

Any restic command from a host using sftp get the error:

Fatal: unable to open repository at sftp:restic:/data/ResticRepo: unable to start the sftp session, error: error receiving version packet from server: packet too long

This morning I was making some changes to optimize how I manage environment variables and backup specifications for multiple machines and when testing I tried to run a backup and got the above error.

Debugging

  • I sudo to the restic user sudo -i -u restic and run restic snapshots and get the same error.
  • I enabled debug logging and ran the snapshot command and it failed with this in the debug log. (I did some reformatting to make it legible)
2026/06/13 08:23:43 restic/main.go:167  main.main 1 
    main []string{"restic", snapshots"}
2026/06/13 08:23:43 restic/main.go:168 main.main  1       
    restic 0.18.0 compiled with go1.24.1 on linux/amd64
2026/06/13 08:23:43 restic/global.go:603 main.innerOpen  1       
    parsing location sftp:restic:/data/ResticRepo
2026/06/13 08:23:43 restic/global.go:598  main.parseConfig 1  
    opening sftp repository at &sftp.Config{User:"", Host:"restic", Port:"", 
         Path:"/data/ResticRepo", Command:"", Args:"", Connections:0x5}
2026/06/13 08:23:43 sftp/sftp.go:147  sftp.Open  1       
    open backend with config sftp.Config{User:"", Host:"restic", Port:"", 
         Path:"/data/ResticRepo", Command:"", Args:"", Connections:0x5}
2026/06/13 08:23:43 sftp/sftp.go:59 sftp.startClient 1       
    start client ssh [restic -s sftp]
2026/06/13 08:23:44 sftp/sftp.go:151  sftp.Open  1       
    unable to start program: unable to start the sftp session, error: error 
        receiving version packet from server: packet too long
2026/06/13 08:23:44 restic/cleanup.go:39  main.Exit 1       
    exiting with status code 1

I don’t know if the “open backend” line is showing a problem or not. It has my host alias as the host and the user is empty. I never ran with debug logging when it was working so I do not know what is should display.

running ssh restic works fine.

running restic -r sftp:restic:/data/ResticRepo fails as shown in the debug log.

My setup came from the documentation where it says “Alternatively, you can create an entry in the ssh configuration file,” on Preparing a new repository — restic 0.19.0-dev documentation

I restored the restic home directory from 6/11 and I still get the error.

Background

I have been using restic to backup my OMV server to another one using restic with sftp. The backup in the wee hours of 6/12 worked fine.

My configuration is:

Both the backup server and the server being backed up are running OpenMediaVault 8.

restic 0.18.0 compiled with go1.24.1 on linux/amd64

All hosts have a restic user that is used to run restic using a restic binary that has been set to allow access to all files.

I have the following variables set in the environment:

RESTIC_REPOSITORY=sftp:restic:/data/ResticRepo
RESTIC_PASSWORD=***
restic=/home/restic/bin/restic
PATH=/home/restic/bin:/home/restic/bin:/usr/local/bin:/usr/bin:/bin

restic in the REPO variable is a host alias from .ssh/config which contains

Host restic
    Hostname omv2.internal
    User restic
    Port 6666
    ServerAliveInterval 60
    ServerAliveCountMax 240
    IdentityFile ~/.ssh/restic

Host *
    HashKnownHosts no
    PreferredAuthentications publickey
    IdentitiesOnly yes

I use a backup script that is run by cron. It runs this command

nice -n 9 /home/restic/bin/restic backup --one-file-system --skip-if-unchanged  --verbose  --tag omv1-full  -e /var/tmp -e /var/run -e /var/lock -e /var/cache -e /lost+found / /root /opt /home /var /srv /usr/local /data /data/VirtualMachines

I finally found the problem. On the backup server the restic user had an echo in the .bashrc file and that caused sftp to have a problem.

Just using ssh to login worked and the echo output showed in the terminal.

One more note:

I found that running

restic -r sftp:restic:/data/ResticRepo -o sftp.command="ssh -vvv restic -s sftp" snapshots

provided much more detailed output that the restic debug log.