aboutsummaryrefslogtreecommitdiffstats
path: root/run_nonhost.go
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--run_nonhost.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/run_nonhost.go b/run_nonhost.go
new file mode 100644
index 0000000..9742774
--- /dev/null
+++ b/run_nonhost.go
@@ -0,0 +1,18 @@
+//go:build !windows || nonhost
+
+package main
+
+import (
+ "errors"
+ "fmt"
+ "os/exec"
+ "strconv"
+)
+
+func command(distribution Distribution, config Config) (*exec.Cmd, error) {
+ if distribution.Username == "" || distribution.Port == 0 {
+ return nil, errors.New("SSH username or port not set, not running.")
+ }
+ args := append([]string{fmt.Sprintf("%s@%s", distribution.Username, config.HostIP), "-p", strconv.Itoa(distribution.Port)}, config.SshArgs...)
+ return exec.Command("ssh", args...), nil
+}