Files
podman/pkg/machine/ssh.go
Brent Baude 3222545ad5 Enabled network over vsock
podman machine with Microsoft HyperV will use hvsock on the guest and
vsock on the guest for its networking.  this pr enables the basics for
this to happen as well as changes to ignition to automatically set this
up with network manager.

the vm binary referenced in this pr is in containers/gvisor-tap-vsock
and will need to be added to distributions.

[NO NEW TESTS NEEDED]
Signed-off-by: Brent Baude <bbaude@redhat.com>
2023-04-17 12:34:37 -05:00

35 lines
851 B
Go

package machine
import (
"fmt"
"os"
"os/exec"
"strconv"
"github.com/sirupsen/logrus"
)
// CommonSSH is a common function for ssh'ing to a podman machine using system-connections
// and a port
func CommonSSH(username, identityPath, name string, sshPort int, inputArgs []string) error {
sshDestination := username + "@localhost"
port := strconv.Itoa(sshPort)
args := []string{"-i", identityPath, "-p", port, sshDestination,
"-o", "StrictHostKeyChecking=no", "-o", "LogLevel=ERROR", "-o", "SetEnv=LC_ALL="}
if len(inputArgs) > 0 {
args = append(args, inputArgs...)
} else {
fmt.Printf("Connecting to vm %s. To close connection, use `~.` or `exit`\n", name)
}
cmd := exec.Command("ssh", args...)
logrus.Debugf("Executing: ssh %v\n", args)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Stdin = os.Stdin
return cmd.Run()
}