0
0
mirror of https://github.com/bpg/terraform-provider-proxmox.git synced 2025-07-05 05:24:01 +00:00

fix(provider): handle IPv6 in ssh client (#1558)

fix(vm): handle IPv6 in ssh client

Signed-off-by: Jordan Garside <jordangarside@Jordans-MacBook-Pro.local>
This commit is contained in:
Jordan Garside 2024-10-01 09:36:11 -07:00 committed by GitHub
parent d226b59e2e
commit 18a7f8ec35
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -473,7 +473,14 @@ func (c *client) openNodeShell(ctx context.Context, node ProxmoxNode) (*ssh.Clie
return nil, fmt.Errorf("failed to determine the home directory: %w", err) return nil, fmt.Errorf("failed to determine the home directory: %w", err)
} }
sshHost := fmt.Sprintf("%s:%d", node.Address, node.Port) var sshHost string
if strings.Contains(node.Address, ":") {
// IPv6
sshHost = fmt.Sprintf("[%s]:%d", node.Address, node.Port)
} else {
// IPv4
sshHost = fmt.Sprintf("%s:%d", node.Address, node.Port)
}
sshPath := path.Join(homeDir, ".ssh") sshPath := path.Join(homeDir, ".ssh")
if _, err = os.Stat(sshPath); os.IsNotExist(err) { if _, err = os.Stat(sshPath); os.IsNotExist(err) {