fix: avoid default value for idf

We could default to ~/.ssh/id_rsa but if that doesn't exist, then we'll
just be confusing people in the logs. Best is to just rely on the
ssh-agent which overrides this anyway. We will document this.

See coop-cloud/organising#277
This commit is contained in:
decentral1se 2021-12-24 15:34:25 +01:00
parent fefb042716
commit dddf84d92b
Signed by: decentral1se
GPG Key ID: 03789458B3D0C410
1 changed files with 9 additions and 8 deletions

View File

@ -475,11 +475,10 @@ func GetContextConnDetails(serverName string) (*dockerSSHPkg.Spec, error) {
func GetHostConfig(hostname, username, port string) (HostConfig, error) {
var hostConfig HostConfig
var host, idf string
if host = ssh_config.Get(hostname, "Hostname"); host == "" {
logrus.Debugf("no hostname found in SSH config, assuming %s", hostname)
host = hostname
if hostname == "" {
if hostname = ssh_config.Get(hostname, "Hostname"); hostname == "" {
logrus.Debugf("no hostname found in SSH config, assuming %s", hostname)
}
}
if username == "" {
@ -500,17 +499,19 @@ func GetHostConfig(hostname, username, port string) (HostConfig, error) {
}
}
idf = ssh_config.Get(hostname, "IdentityFile")
if idf != "" {
if idf := ssh_config.Get(hostname, "IdentityFile"); idf != "" && idf != "~/.ssh/identity" {
var err error
idf, err = identityFileAbsPath(idf)
if err != nil {
return hostConfig, err
}
hostConfig.IdentityFile = idf
} else {
logrus.Debugf("no identity file found in SSH config for %s", hostname)
hostConfig.IdentityFile = ""
}
hostConfig.Host = host
hostConfig.Host = hostname
hostConfig.Port = port
hostConfig.User = username