mirror of
https://github.com/containers/podman.git
synced 2025-12-11 09:18:34 +08:00
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>
This commit is contained in:
19
vendor/github.com/containers/common/pkg/config/config.go
generated
vendored
19
vendor/github.com/containers/common/pkg/config/config.go
generated
vendored
@@ -613,6 +613,9 @@ type Destination struct {
|
||||
|
||||
// Identity file with ssh key, optional
|
||||
Identity string `toml:"identity,omitempty"`
|
||||
|
||||
// isMachine describes if the remote destination is a machine.
|
||||
IsMachine bool `toml:"is_machine,omitempty"`
|
||||
}
|
||||
|
||||
// NewConfig creates a new Config. It starts with an empty config and, if
|
||||
@@ -1235,32 +1238,32 @@ func Reload() (*Config, error) {
|
||||
return defConfig()
|
||||
}
|
||||
|
||||
func (c *Config) ActiveDestination() (uri, identity string, err error) {
|
||||
func (c *Config) ActiveDestination() (uri, identity string, machine bool, err error) {
|
||||
if uri, found := os.LookupEnv("CONTAINER_HOST"); found {
|
||||
if v, found := os.LookupEnv("CONTAINER_SSHKEY"); found {
|
||||
identity = v
|
||||
}
|
||||
return uri, identity, nil
|
||||
return uri, identity, false, nil
|
||||
}
|
||||
connEnv := os.Getenv("CONTAINER_CONNECTION")
|
||||
switch {
|
||||
case connEnv != "":
|
||||
d, found := c.Engine.ServiceDestinations[connEnv]
|
||||
if !found {
|
||||
return "", "", fmt.Errorf("environment variable CONTAINER_CONNECTION=%q service destination not found", connEnv)
|
||||
return "", "", false, fmt.Errorf("environment variable CONTAINER_CONNECTION=%q service destination not found", connEnv)
|
||||
}
|
||||
return d.URI, d.Identity, nil
|
||||
return d.URI, d.Identity, d.IsMachine, nil
|
||||
|
||||
case c.Engine.ActiveService != "":
|
||||
d, found := c.Engine.ServiceDestinations[c.Engine.ActiveService]
|
||||
if !found {
|
||||
return "", "", fmt.Errorf("%q service destination not found", c.Engine.ActiveService)
|
||||
return "", "", false, fmt.Errorf("%q service destination not found", c.Engine.ActiveService)
|
||||
}
|
||||
return d.URI, d.Identity, nil
|
||||
return d.URI, d.Identity, d.IsMachine, nil
|
||||
case c.Engine.RemoteURI != "":
|
||||
return c.Engine.RemoteURI, c.Engine.RemoteIdentity, nil
|
||||
return c.Engine.RemoteURI, c.Engine.RemoteIdentity, false, nil
|
||||
}
|
||||
return "", "", errors.New("no service destination configured")
|
||||
return "", "", false, errors.New("no service destination configured")
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
Reference in New Issue
Block a user