Skip to content

Commit

Permalink
fix bastion ssh config extension
Browse files Browse the repository at this point in the history
  • Loading branch information
corpix committed Aug 21, 2022
1 parent 317a5c2 commit 553c61d
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,23 +304,21 @@ func (p *Provider) NewSsh(resource ResourceBox) *Ssh {
bastionHost, _ := bastionSettings[KeySshHost].(string)
if bastionHost != "" {
bastionConfigMap := p.SshConfigMap(bastionSettings)
if bastionConfigMap.Len() > 0 {
// NOTE: base ssh configuration (ssh {}) extended with bastion ssh configuration (ssh { bastion {} })
extendedBastionConfigMap := configMap.Copy()
extendedBastionConfigMap.Extend(bastionConfigMap)

bastion := NewSsh(
SshOptionConfigMap(extendedBastionConfigMap),
SshOptionNonInteractive(),
SshOptionIORedirection("%h", "%p"),
SshOptionHost(bastionHost),
)
command, arguments, _ := bastion.Command()
configMap.Set(
SshConfigKeyProxyCommand,
strings.Join(append([]string{command}, arguments...), " "),
)
}
// NOTE: base ssh configuration (ssh {}) extended with bastion ssh configuration (ssh { bastion {} })
extendedBastionConfigMap := configMap.Copy()
extendedBastionConfigMap.Extend(bastionConfigMap)

bastion := NewSsh(
SshOptionConfigMap(extendedBastionConfigMap),
SshOptionNonInteractive(),
SshOptionIORedirection("%h", "%p"),
SshOptionHost(bastionHost),
)
command, arguments, _ := bastion.Command()
configMap.Set(
SshConfigKeyProxyCommand,
strings.Join(append([]string{command}, arguments...), " "),
)
}

if configMap.Len() > 0 {
Expand Down

0 comments on commit 553c61d

Please sign in to comment.