diff options
author | Ashley Cui <acui@redhat.com> | 2021-03-22 13:23:22 -0400 |
---|---|---|
committer | baude <bbaude@redhat.com> | 2021-03-25 08:46:43 -0500 |
commit | e7661137373b5f87bf6ec45e32326821b172ce7b (patch) | |
tree | 34910aceb3e4188f4e66a128eba502e12e659308 /pkg/machine/qemu | |
parent | b5f54a9b23e8d9418700494da9aa78d8db354c43 (diff) | |
download | podman-e7661137373b5f87bf6ec45e32326821b172ce7b.tar.gz podman-e7661137373b5f87bf6ec45e32326821b172ce7b.tar.bz2 podman-e7661137373b5f87bf6ec45e32326821b172ce7b.zip |
Add --execute flag to podman machine ssh
--execute, -e allows to execute a command through ssh
Signed-off-by: Ashley Cui <acui@redhat.com>
Diffstat (limited to 'pkg/machine/qemu')
-rw-r--r-- | pkg/machine/qemu/machine.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/pkg/machine/qemu/machine.go b/pkg/machine/qemu/machine.go index 92a16dda7..30d96ce08 100644 --- a/pkg/machine/qemu/machine.go +++ b/pkg/machine/qemu/machine.go @@ -293,9 +293,14 @@ func (v *MachineVM) SSH(name string, opts machine.SSHOptions) error { sshDestination := v.RemoteUsername + "@localhost" port := strconv.Itoa(v.Port) - fmt.Printf("Connecting to vm %s. To close connection, use `~.` or `exit`\n", v.Name) + args := []string{"-i", v.IdentityPath, "-p", port, sshDestination} + if opts.Execute { + args = append(args, opts.Args...) + } else { + fmt.Printf("Connecting to vm %s. To close connection, use `~.` or `exit`\n", v.Name) + } - cmd := exec.Command("ssh", "-i", v.IdentityPath, "-p", port, sshDestination) + cmd := exec.Command("ssh", args...) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr cmd.Stdin = os.Stdin |