Getting SFTP and Windows to work

Hi,
I’m desesperately trying to get restic to work on windows as client for a SFTP Linux box.
Using Windows 11 22H2 x64 to connect to a RHEL9 server, using restic 0.18.1.
I can connect via “plain” ssh from windows:

C:\GIT\>ssh -p 22 -i ssh_key.txt restic@192.168.200.204
Last login: Mon Apr  6 22:30:08 2026 from 192.168.80.33
[restic@rhel9~]$ exit
logout
Connection to 192.168.81.204 closed.

if I happen to use restic, terminal freezes (CTRL+C will signal interrupt received, cleaning up message but terminal will still be frozen):

C:\GIT\>set RESTIC_PASSWORD=test
C:\GIT\>set RESTIC_REPOSITORY=sftp:restic@192.168.200.204:/repo
C:\GIT\>set DEBUG_LOG=restic.log
C:\GIT\>restic -o sftp.command="ssh -p 22 -i ssh_key.txt restic@192.168.200.204" ls latest
subprocess ssh: Pseudo-terminal will not be allocated because stdin is not a terminal.

The above command produced the following log file (last 3 lines appeared once I typed CTRL+C):

2026/04/06 22:36:30 restic/main.go:167	main.main	1	main []string{"restic", "-o", "sftp.command=ssh -p 22 -i ssh_key.txt restic@192.168.81.204", "ls", "latest"}
2026/04/06 22:36:30 restic/main.go:168	main.main	1	restic 0.18.1 compiled with go1.25.1 on windows/amd64
2026/04/06 22:36:30 restic/global.go:603	main.innerOpen	1	parsing location sftp:restic@192.168.81.204:/repo
2026/04/06 22:36:30 restic/global.go:598	main.parseConfig	1	opening sftp repository at &sftp.Config{User:"restic", Host:"192.168.81.204", Port:"", Path:"/repo", Command:"ssh -p 22 -i ssh_key.txt restic@192.168.200.204", Args:"", Connections:0x5}
2026/04/06 22:36:30 sftp/sftp.go:147	sftp.Open	1	open backend with config sftp.Config{User:"restic", Host:"192.168.81.204", Port:"", Path:"/repo", Command:"ssh -p 22 -i ssh_key.txt restic@192.168.200.204", Args:"", Connections:0x5}
2026/04/06 22:36:30 sftp/sftp.go:59	sftp.startClient	1	start client ssh [-p 22 -i ssh_key.txt restic@192.168.200.204]
2026/04/06 22:40:07 restic/cleanup.go:25	main.cleanupHandler	8	signal interrupt received, cleaning up
2026/04/06 22:40:07 restic/global.go:286	main.Warnf	8	                                                                                                                                                           
signal interrupt received, cleaning up

I also tried using the plink solution I’ve read on various issues / forum entries, but I think there’s something wrong with the sftp call which expects arguments (I’ve tried this on a RHEL9 and a Debian 11, both return the same result):

C:\GIT\>restic -o sftp.command="./plink.exe -l restic -pw restic 192.168.200.204 sftp" ls snapshots
debug log file restic.log
debug enabled
subprocess ./plink.exe: usage: sftp [-46AaCfNpqrv] [-B buffer_size] [-b batchfile] [-c cipher]
subprocess ./plink.exe:           [-D sftp_server_path] [-F ssh_config] [-i identity_file]
subprocess ./plink.exe:           [-J destination] [-l limit] [-o ssh_option] [-P port]
subprocess ./plink.exe:           [-R num_requests] [-S program] [-s subsystem | sftp_server]
subprocess ./plink.exe:           destination
Fatal: unable to open repository at sftp:restic@192.168.200.204:/repo: unable to start the sftp session, error: error receiving version packet from server: server unexpectedly closed connection: unexpected EOF

I’ve also tried to “force” a sftp server for my restic user on the linux side by configuring sshd_config, without any more luck.
I’m quite puzzled on how to get SFTP working on Windows. Anyone has more experience here ?

PS: Sorry, this is a duplicate of github issue #5155, but after posting there I thought the forum would probably be a better place for this.

@deajan not much experience with sftp on Windows, but I have a few questions when I see what you tried.

For example: I can ssh from Windows to a Linux box just like you. Then the restic doc sftp init example already works for me. No need to pass complicated ssh or plink options via -o sftp.command.

restic -r sftp:restic@192.168.200.204:/repo init

Did you try this? What is the result?

Thanks, but I did read the documenation before posting.

Basic settings work with out of the box deployments, whereas you need to use -o sftp.command if you want to specify a custom ssh port or a custom key file, hence my search.

Also, I need the same command to work on Windows 7 up to 11, and windows 7 and 8 don’t have ssh integrated, hence I use plink.exe or even klink.exe so I get to use automatic known_hosts accpetance.

I finally found i was missing the -s option in my plink.exe invocation.