configure ssh options

This commit is contained in:
Воробьев Павел
2020-09-15 16:43:54 +03:00
parent e93cf26857
commit a28b8b5da5
3 changed files with 26 additions and 0 deletions

View File

@@ -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)

View File

@@ -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)

View File

@@ -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 {