podman-api-rs icon indicating copy to clipboard operation
podman-api-rs copied to clipboard

Support for Podman over ssh remote connection

Open lmtr0 opened this issue 3 years ago • 7 comments

Hello there, good day!

At work, I use Golang with podman, and they have a way to connect to other machines securely through ssh tcp streams. I think it would be a great addition to this library as well :)

Here is the ssh library I found that supports the stream pass-through. Here are some connection examples:

// connection examples:
//   - ssh://<user>@<host>[:port]/run/podman/podman.sock?secure=True
//   - unix://tmp/__podman.sock -t 0

Then this library would parse and choose the most appropriate one for the job.

I haven't explored this codebase enough to see how much work It would take, so If you need any help, please let me know

lmtr0 avatar Nov 29 '22 12:11 lmtr0

Also, the golang library is called bindings and it's in the pkg directory over in https://github.com/containers/podman/tree/main/pkg/bindings

lmtr0 avatar Nov 29 '22 12:11 lmtr0

Thank you for the report, that is indeed an interesting idea. It would probably require creating some sort of compatibility wrapper for ssh connection that would implement the tower::Service trait for integration with hyper, similar to what hyperlocal does for a unix socket but that seems doable. I will look into this when I get some more free time.

vv9k avatar Dec 04 '22 13:12 vv9k

I agree, I will explore more the go code and come back with hopefully how they implemented on their side

lmtr0 avatar Dec 05 '22 20:12 lmtr0

The way podman does is with a full abstraction of the http client to use ssh https://github.com/containers/podman/blob/main/pkg/bindings/connection.go#L94

lmtr0 avatar Dec 20 '22 13:12 lmtr0

there is a stream struct on the ssh2 library https://docs.rs/ssh2/latest/ssh2/struct.Stream.html

lmtr0 avatar Dec 20 '22 13:12 lmtr0

A way we could do it is to abstract the hole http client struct and use different clients for different use cases :thinking:

lmtr0 avatar Dec 20 '22 13:12 lmtr0

I think this is necessary for supporting macOS as I think it works by connecting to a virtual machine over ssh.

$ podman system connection  list
Name                         URI                                                         Identity                                                      Default     ReadWrite
podman-machine-default       ssh://[email protected]:63169/run/user/501/podman/podman.sock  /Users/blazzy/.local/share/containers/podman/machine/machine  true        true

blazzy avatar Jun 17 '24 20:06 blazzy