francoismichel / ssh3

SSH3: faster and rich secure shell using HTTP/3, checkout our article here: https://arxiv.org/abs/2312.08396 and our Internet-Draft: https://datatracker.ietf.org/doc/draft-michel-ssh3/
https://arxiv.org/abs/2312.08396
Apache License 2.0
3.19k stars 82 forks source link

scp3 or sftp3 possible? #36

Open tigerinus opened 6 months ago

tigerinus commented 6 months ago

The shell session works well. The missing piece is file transfer.

Any plan?

SuperSandro2000 commented 6 months ago

The SCP protocol is deprecated and recent versions of scp also use SFTP.

francoismichel commented 6 months ago

It is totally possible and would be great ! I would first like to do a small review of the technologies we could use for it though. SFTP is cool, but maybe something like WebDAV is a good candidate as well. Let me know if you have other ideas. In the meantime we could imagine coming up with a temporary solution that would only need to be implemented by the client. By doing so, we don't have to update the whole SSH3 protocol right now for "scp3" and only update it when we come up with a solid design.

siepkes commented 6 months ago

Meanwhile you might be able to use rsync. Here is an example which uses rsync with netcat: https://superuser.com/questions/1330291/use-rsync-with-nc-as-transport-layer#1517462

It might be possible to modify the example to use SSH3 with cat over the terminal instead of netcat.

francoismichel commented 6 months ago

Based on @siepkes's example, I pushed on branch rsync_compat a slight CLI modification to be compatible with rsync and how it calls its underlying remote shell:

1) rsync calls the remote shell protocol with the -l <username> CLI arg to set the username, so I added that arg to ssh3 2) rsync does not like us specifying the request path in the remote host url like we classically do in ssh3. I therefore added the -url-path <secret-path> CLI arg on the client specifying the url path to query on the remote host.

Here is an example that works with rsync and ssh3:

rsync -a --info=progress2 --rsh 'ssh3 -privkey ~/.ssh3/id_rsa -url-path /ssh3-inl' user@host:~/remote-dir/ ./rsync_output/

This will copy recursively the directory ~/remote-dir on the remote host and place its content in the ./rsync_output local directory.

It works well, but rsync ends with a broken pipe, I don't know why, maybe SSH3 closes the connection too early. We should investigate but right now the files are copied correctly and it seems to work with several files as well.

Let me know your thoughts !

AlexanderYastrebov commented 6 months ago

It works well, but rsync ends with a broken pipe

In my case old rsync version failed with rsync error: sibling process terminated abnormally (code 16) which was caused by ssh3 receiving SIGPIPE. I could not track down why it gets it but its possible to workaround by adding signal.Ignore(syscall.SIGPIPE) to the main.

rsync does not like us specifying the request path ... therefore added the -url-path

It also does not support port (see https://stackoverflow.com/questions/4549945/is-it-possible-to-specify-a-different-ssh-port-when-using-rsync) so I've added -url-port flag, see https://github.com/AlexanderYastrebov/ssh3/tree/rsync_compat2