summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorAshley Cui <acui@redhat.com>2021-04-01 13:31:42 -0400
committerAshley Cui <acui@redhat.com>2021-04-01 13:51:02 -0400
commitf8bc391e349f8e67ad35c802be4c99dc3eabe4a2 (patch)
tree1e5210f1ab43e4ecd5cfcf4deb4a1513cf600119 /pkg
parent8b599c51268dc141bd963d8b5d3f25feadfcbb0e (diff)
downloadpodman-f8bc391e349f8e67ad35c802be4c99dc3eabe4a2.tar.gz
podman-f8bc391e349f8e67ad35c802be4c99dc3eabe4a2.tar.bz2
podman-f8bc391e349f8e67ad35c802be4c99dc3eabe4a2.zip
Add ssh connection to root user
When initing a VM, create two add connections - one to user, one to root. podman machine remove removes both connections as well. [NO TESTS NEEDED] Signed-off-by: Ashley Cui <acui@redhat.com>
Diffstat (limited to 'pkg')
-rw-r--r--pkg/machine/ignition.go14
-rw-r--r--pkg/machine/qemu/machine.go9
2 files changed, 19 insertions, 4 deletions
diff --git a/pkg/machine/ignition.go b/pkg/machine/ignition.go
index a68d68ac3..cc5c01de6 100644
--- a/pkg/machine/ignition.go
+++ b/pkg/machine/ignition.go
@@ -55,10 +55,16 @@ func NewIgnitionFile(ign DynamicIgnition) error {
}
ignPassword := Passwd{
- Users: []PasswdUser{{
- Name: ign.Name,
- SSHAuthorizedKeys: []SSHAuthorizedKey{SSHAuthorizedKey(ign.Key)},
- }},
+ Users: []PasswdUser{
+ {
+ Name: ign.Name,
+ SSHAuthorizedKeys: []SSHAuthorizedKey{SSHAuthorizedKey(ign.Key)},
+ },
+ {
+ Name: "root",
+ SSHAuthorizedKeys: []SSHAuthorizedKey{SSHAuthorizedKey(ign.Key)},
+ },
+ },
}
ignStorage := Storage{
diff --git a/pkg/machine/qemu/machine.go b/pkg/machine/qemu/machine.go
index 2652ebc10..fd22f465b 100644
--- a/pkg/machine/qemu/machine.go
+++ b/pkg/machine/qemu/machine.go
@@ -168,6 +168,11 @@ func (v *MachineVM) Init(opts machine.InitOptions) error {
if err := machine.AddConnection(&uri, v.Name, filepath.Join(sshDir, v.Name), opts.IsDefault); err != nil {
return err
}
+
+ uriRoot := machine.SSHRemoteConnection.MakeSSHURL("localhost", "/run/podman/podman.sock", strconv.Itoa(v.Port), "root")
+ if err := machine.AddConnection(&uriRoot, v.Name+"-root", filepath.Join(sshDir, v.Name), opts.IsDefault); err != nil {
+ return err
+ }
} else {
fmt.Println("An ignition path was provided. No SSH connection was added to Podman")
}
@@ -357,6 +362,10 @@ func (v *MachineVM) Remove(name string, opts machine.RemoveOptions) (string, fun
if err := machine.RemoveConnection(v.Name); err != nil {
logrus.Error(err)
}
+ if err := machine.RemoveConnection(v.Name + "-root"); err != nil {
+ logrus.Error(err)
+ }
+
vmConfigDir, err := machine.GetConfDir(vmtype)
if err != nil {
return "", nil, err