Closed hbgl closed 2 years ago
Your step 1 is not entirely accurate. It does not start an sftp
client process, it creates an ssh
client process with the command-line argument -s sftp
which is a raw connection to the SFTP as expected by this package, rather than the sftp
client itself, which as you note only accepts text commands.
I’ve tested calling ssh mycomputer -s sftp
and it does indeed open a raw SFTP pipe to the remote machine.
From point 2 onwards, you are correct.
Many thanks!
Hi, let me preface this by saying that I am not a direct user of this package and I am not even a Go developer. I stumbled upon this project because I use the backup tool restic which is written in Go and which does use this package. With restic you can pass it a command as an option (e.g.
-o sftp.command="foobar"
) that creates an SFTP client and then restic uses that client to send and receive data. I found that mechanism quite intricate so I wanted to know how it works, which is why I am here.I read through the source code and here is what I gathered so far:
Is this correct so far? Is there any external documentation about how to send and receive raw packages via stdin and stdout using the sftp client? I tried starting the sftp client and sending it packets via stdin but it only accepts text commands. I must be missing something here.
Thanks for reading this far and if there is a better channel to ask these sort of questions, please let me know.