ssh command configurable

This commit is contained in:
Pavel Vorobyov
2020-03-17 15:51:16 +03:00
parent f3877d7e0b
commit abb8943266
4 changed files with 17 additions and 1 deletions

View File

@@ -135,6 +135,7 @@ func New(cfg *config.XCConfig, backend store.Backend) (*Cli, error) {
remote.SetDebug(cli.debug)
remote.SetUsePasswordManager(cli.usePasswordMgr)
remote.SetNumThreads(cli.sshThreads)
remote.SetSSHCommand(cfg.SSHCommand)
remote.SetRemoteEnvironment(cfg.RemoteEnvironment)
// interpreter

View File

@@ -27,6 +27,7 @@ distribute = tar
[executer]
ssh_threads = 50
ssh_connect_timeout = 1
ssh_command = /usr/bin/ssh
progress_bar = true
prepend_hostnames = true
remote_tmpdir = /tmp
@@ -70,6 +71,7 @@ type XCConfig struct {
User string
SSHThreads int
SSHConnectTimeout int
SSHCommand string
PingCount int
RemoteTmpdir string
Mode string
@@ -109,6 +111,7 @@ const (
defaultProgressbar = true
defaultPrependHostnames = true
defaultSSHConnectTimeout = 1
defaultSSHCommand = "/usr/bin/ssh"
defaultLogFile = ""
defaultExitConfirm = true
defaultExecConfirm = true
@@ -208,6 +211,12 @@ func read(filename string, secondPass bool) (*XCConfig, error) {
}
cfg.SSHThreads = threads
sshCommand, err := props.GetString("executer.ssh_command")
if err != nil {
sshCommand = defaultSSHCommand
}
cfg.SSHCommand = sshCommand
ctimeout, err := props.GetInt("executer.ssh_connect_timeout")
if err != nil {
ctimeout = defaultSSHConnectTimeout

View File

@@ -60,7 +60,7 @@ func createSSHCmd(host string, argv string) *exec.Cmd {
params = append(params, "-c", argv)
}
log.Debugf("Created command ssh %v", params)
return exec.Command("ssh", params...)
return exec.Command(sshCommand, params...)
}
func getInterpreter() []string {

View File

@@ -25,6 +25,7 @@ var (
poolLock *sync.Mutex
poolSize int
remoteEnvironment map[string]string
sshCommand string
noneInterpreter string
suInterpreter string
@@ -39,6 +40,11 @@ func Initialize(numThreads int, username string) {
SetRaise(RTNone)
}
// SetSSHCommand sets ssh binary path to be used in createSSHCommand
func SetSSHCommand(command string) {
sshCommand = command
}
// SetInterpreter sets none-raise interpreter
func SetInterpreter(interpreter string) {
noneInterpreter = interpreter