From 783a6fe604cdedeb386e9abad59b7d87d0d119e0 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Mon, 17 May 2021 08:37:23 +0200 Subject: [PATCH] config: config.yaml: add global "ssh_user" option This option is used as default value when the host option "ssh_user" is empty. Like the host option it defaults to an empty value which tells `ssh` to use the current user. --- cmd/safcm/config/config.go | 2 ++ cmd/safcm/sync.go | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/safcm/config/config.go b/cmd/safcm/config/config.go index fafa791..74f486e 100644 --- a/cmd/safcm/config/config.go +++ b/cmd/safcm/config/config.go @@ -34,6 +34,8 @@ type Config struct { DetectGroups []string `yaml:"detect_groups"` GroupPriority []string `yaml:"group_priority"` + + SshUser string `yaml:"ssh_user"` } func LoadConfig() (*Config, error) { diff --git a/cmd/safcm/sync.go b/cmd/safcm/sync.go index 0f7c54f..6f38daf 100644 --- a/cmd/safcm/sync.go +++ b/cmd/safcm/sync.go @@ -370,7 +370,11 @@ func (s *Sync) Host(wg *sync.WaitGroup) error { }() // Connect to remote host - err := conn.DialSSH(s.host.SshUser, s.host.Name, s.config.SshConfig) + user := s.host.SshUser + if user == "" { + user = s.config.SshUser + } + err := conn.DialSSH(user, s.host.Name, s.config.SshConfig) if err != nil { return err } -- 2.43.2