podman-api-rs
podman-api-rs copied to clipboard
Support for Podman over ssh remote connection
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
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
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.
I agree, I will explore more the go code and come back with hopefully how they implemented on their side
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
there is a stream struct on the ssh2 library https://docs.rs/ssh2/latest/ssh2/struct.Stream.html
A way we could do it is to abstract the hole http client struct and use different clients for different use cases :thinking:
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