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:
parent
fefb042716
commit
dddf84d92b
|
@ -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 == "" {
|
||||
if hostname == "" {
|
||||
if hostname = ssh_config.Get(hostname, "Hostname"); hostname == "" {
|
||||
logrus.Debugf("no hostname found in SSH config, assuming %s", hostname)
|
||||
host = 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
|
||||
|
||||
|
|
Loading…
Reference in New Issue