artyom-poptsov / guile-ssh

Guile-SSH is a library that provides access to the SSH protocol for GNU Guile programs.
https://memory-heap.org/~avp/projects/guile-ssh
GNU General Public License v3.0
60 stars 12 forks source link

connection sharing for local rsync commands #24

Closed vapniks closed 3 years ago

vapniks commented 4 years ago

I want to run several rsync commands (on localhost) using the same ssh connection. I can do this using shell commands like this:

> ssh -M -S ~/.ssh/%C -N -f <USR>@<HOST>
> rsync -au -e "ssh -S ~/.ssh/%C <USR>@<HOST>" lfile1 rfile1 
> rsync -au -e "ssh -S ~/.ssh/%C <USR>@<HOST>" lfile2 rfile2
> ssh -O exit <USR>@<HOST>

but how would I achieve the same thing using guile-ssh? I see no mention of control sockets in the manual, and I don't see any way to use channels to run rsync locally.

artyom-poptsov commented 4 years ago

It would be helpful if you could add some code example of what you want accomplish.

Nevertheless, if you are using Guile-SSH remote pipes, then all commands executed on a session will go through the same connection to a host. The idea is that a Guile-SSH session holds the connection to a server and Guile-SSH channels are in charge of data exchange through the connection (in other words, channels do multiplexing.) Here's an ASCII image from the Guile-SSH documentation (3.1.1 Session Management):

     [client]                      [server]

         \____________________________/  SSH session

          ============================
          ============================   SSH channels
          ============================
          ____________________________
         /                            \

Hope it helps,

Artyom.

vapniks commented 4 years ago

I want to use guile-ssh to open an ssh connection to a remote host, and then run several rsync commands on localhost which all make use of that same ssh connection. I could do this by just making several guile system calls replicating the previously mentioned shell commands, but that would get a bit messy, and I would prefer an idiomatic guile-ssh solution if there is one. The explanation you gave above doesn't tell me how I can do this, because as far as I can tell channels can only be used to run commands on the remote host.

vapniks commented 4 years ago

I just checked the libssh & libssh2 website, github page and mailing lists and the only mention of "ControlMaster" that I can find is this unanswered query: https://www.libssh.org/archive/libssh/2019-09/0000006.html So it appears that functionality is not available in libssh, and hence guile-ssh.