aboutsummaryrefslogtreecommitdiffstats
path: root/run_nonhost.go
blob: 9742774cf64311e9ce9c658eaf26856fef83ab9c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
}