diff options
author | Charlie Doern <cdoern@redhat.com> | 2022-08-23 11:04:54 -0400 |
---|---|---|
committer | cdoern <cbdoer23@g.holycross.edu> | 2022-09-26 18:35:01 -0400 |
commit | 2e4e1bb97cdd0fbef7ada673fa97f6b4989998eb (patch) | |
tree | de2e77c1852b505891c11d4cecfac5a1945abf0d /cmd | |
parent | 5fc6d95a947bdf0e0bf013ee282c4a0f99b52a5a (diff) | |
download | podman-2e4e1bb97cdd0fbef7ada673fa97f6b4989998eb.tar.gz podman-2e4e1bb97cdd0fbef7ada673fa97f6b4989998eb.tar.bz2 podman-2e4e1bb97cdd0fbef7ada673fa97f6b4989998eb.zip |
podman machine ssh handling
add the key used in newly initialized machines to the user's known_hosts file. This ensures that golang will be able to ssh into the machine using
podman-remote. Also, remove the /dev/null redirection for podman machine ssh's known_hosts file.
resolves #15347
Signed-off-by: Charlie Doern <cdoern@redhat.com>
Signed-off-by: cdoern <cbdoer23@g.holycross.edu>
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/podman/machine/ssh.go | 2 | ||||
-rw-r--r-- | cmd/podman/root.go | 19 | ||||
-rw-r--r-- | cmd/podman/system/connection/list.go | 5 |
3 files changed, 15 insertions, 11 deletions
diff --git a/cmd/podman/machine/ssh.go b/cmd/podman/machine/ssh.go index 8534b8efa..1cadce916 100644 --- a/cmd/podman/machine/ssh.go +++ b/cmd/podman/machine/ssh.go @@ -101,7 +101,7 @@ func remoteConnectionUsername() (string, error) { if err != nil { return "", err } - dest, _, err := cfg.ActiveDestination() + dest, _, _, err := cfg.ActiveDestination() if err != nil { return "", err } diff --git a/cmd/podman/root.go b/cmd/podman/root.go index 9e3ff48aa..5c65be96d 100644 --- a/cmd/podman/root.go +++ b/cmd/podman/root.go @@ -176,7 +176,7 @@ func persistentPreRunE(cmd *cobra.Command, args []string) error { setupConnection := func() error { var err error - cfg.URI, cfg.Identity, err = cfg.ActiveDestination() + cfg.URI, cfg.Identity, cfg.MachineMode, err = cfg.ActiveDestination() if err != nil { return fmt.Errorf("failed to resolve active destination: %w", err) } @@ -368,10 +368,13 @@ func loggingHook() { func rootFlags(cmd *cobra.Command, opts *entities.PodmanConfig) { cfg := opts.Config - srv, uri, ident := resolveDestination() + srv, uri, ident, machine := resolveDestination() lFlags := cmd.Flags() + // non configurable option to help ssh dialing + opts.MachineMode = machine + sshFlagName := "ssh" lFlags.StringVar(&opts.SSHMode, sshFlagName, string(ssh.GolangMode), "define the ssh mode") _ = cmd.RegisterFlagCompletionFunc(sshFlagName, common.AutocompleteSSH) @@ -513,26 +516,26 @@ func rootFlags(cmd *cobra.Command, opts *entities.PodmanConfig) { } } -func resolveDestination() (string, string, string) { +func resolveDestination() (string, string, string, bool) { if uri, found := os.LookupEnv("CONTAINER_HOST"); found { var ident string if v, found := os.LookupEnv("CONTAINER_SSHKEY"); found { ident = v } - return "", uri, ident + return "", uri, ident, false } cfg, err := config.ReadCustomConfig() if err != nil { logrus.Warning(fmt.Errorf("unable to read local containers.conf: %w", err)) - return "", registry.DefaultAPIAddress(), "" + return "", registry.DefaultAPIAddress(), "", false } - uri, ident, err := cfg.ActiveDestination() + uri, ident, machine, err := cfg.ActiveDestination() if err != nil { - return "", registry.DefaultAPIAddress(), "" + return "", registry.DefaultAPIAddress(), "", false } - return cfg.Engine.ActiveService, uri, ident + return cfg.Engine.ActiveService, uri, ident, machine } func formatError(err error) string { diff --git a/cmd/podman/system/connection/list.go b/cmd/podman/system/connection/list.go index 190a68d52..3c1a42453 100644 --- a/cmd/podman/system/connection/list.go +++ b/cmd/podman/system/connection/list.go @@ -105,8 +105,9 @@ func inspect(cmd *cobra.Command, args []string) error { r := namedDestination{ Name: k, Destination: config.Destination{ - Identity: v.Identity, - URI: v.URI, + Identity: v.Identity, + URI: v.URI, + IsMachine: v.IsMachine, }, Default: def, } |