diff --git a/cli/cli.go b/cli/cli.go index b4f4cbf..727e1ff 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -139,6 +139,7 @@ func New(cfg *config.XCConfig, backend store.Backend) (*Cli, error) { remote.SetNumThreads(cli.sshThreads) remote.SetSSHCommand(cfg.SSHCommand) remote.SetRemoteEnvironment(cfg.RemoteEnvironment) + remote.ApplyConfiguredOptions(cfg.SSHOptions) // interpreter cli.setInterpreter("none", cfg.Interpreter) diff --git a/config/config.go b/config/config.go index 260374d..ed3e5b2 100644 --- a/config/config.go +++ b/config/config.go @@ -37,6 +37,14 @@ interpreter = bash interpreter_sudo = sudo bash interpreter_su = su - +[ssh] +PasswordAuthentication = no +PubkeyAuthentication = yes +StrictHostKeyChecking = no +TCPKeepAlive = yes +ServerAliveCountMax = 12 +ServerAliveInterval = 5 + [backend] type = conductor url = http://c.inventoree.ru @@ -71,6 +79,7 @@ type XCConfig struct { SSHThreads int SSHConnectTimeout int SSHCommand string + SSHOptions map[string]string RemoteTmpdir string Mode string RaiseType string @@ -165,6 +174,7 @@ func read(filename string, secondPass bool) (*XCConfig, error) { cfg.BackendCfg = &BackendConfig{Type: BTIni, Options: make(map[string]string)} cfg.LocalEnvironment = make(map[string]string) cfg.RemoteEnvironment = make(map[string]string) + cfg.SSHOptions = make(map[string]string) hf, err := props.GetString("main.history_file") if err != nil { @@ -298,6 +308,14 @@ func read(filename string, secondPass bool) (*XCConfig, error) { } cfg.PrependHostnames = phn + sshOptsKeys, err := props.Subkeys("ssh") + if err == nil { + for _, key := range sshOptsKeys { + nsKey := fmt.Sprintf("ssh.%s", key) + cfg.SSHOptions[key], _ = props.GetString(nsKey) + } + } + bkeys, err := props.Subkeys("backend") if err != nil { return nil, fmt.Errorf("Backend configuration error: %s", err) diff --git a/remote/ssh.go b/remote/ssh.go index c985cdf..a1b2094 100644 --- a/remote/ssh.go +++ b/remote/ssh.go @@ -15,6 +15,13 @@ var ( } ) +// ApplyConfiguredOptions merges default options and configured ones +func ApplyConfiguredOptions(cfgOptions map[string]string) { + for k, v := range cfgOptions { + sshOptions[k] = v + } +} + func sshOpts() (params []string) { params = make([]string, 0) for opt, value := range sshOptions {