Skip to content

Conversation

@clarsen
Copy link
Contributor

@clarsen clarsen commented Oct 13, 2025

Description

removed ipv6 address wrapping code because golang net.JoinHostPort already wraps ipv6 addresses in '[' and ']'. double wrapping causes ssh communicator to fail.

Resolved Issues

If your PR resolves any open issue(s), please indicate them like this so they will be closed when your PR is merged:

This reverts the fix #406 for this issue #333 (comment)

Logs before this PR

2025/10/13 23:00:23 packer-plugin-vsphere_v2.1.0-dev_x5.0_linux_amd64 plugin: 2025/10/13 23:00:23 VM IP acquired: 2620:83:8008:161::17
2025/10/13 23:00:23 packer-plugin-vsphere_v2.1.0-dev_x5.0_linux_amd64 plugin: 2025/10/13 23:00:23 VM IP is still the same: 2620:83:8008:161::17
...
2025/10/13 23:00:28 packer-plugin-vsphere_v2.1.0-dev_x5.0_linux_amd64 plugin: 2025/10/13 23:00:28 VM IP seems stable enough: [2620:83:8008:161::17]
2025/10/13 23:00:28 ui: ==> vsphere-iso: IP address: [2620:83:8008:161::17]
2025/10/13 23:00:28 ui: ==> vsphere-iso: Using SSH communicator to connect: [2620:83:8008:161::17]
2025/10/13 23:00:28 packer-plugin-vsphere_v2.1.0-dev_x5.0_linux_amd64 plugin: 2025/10/13 23:00:28 [INFO] Waiting for SSH, up to timeout: 30m0s
2025/10/13 23:00:28 ui: ==> vsphere-iso: Waiting for SSH to become available...
2025/10/13 23:00:28 packer-plugin-vsphere_v2.1.0-dev_x5.0_linux_amd64 plugin: 2025/10/13 23:00:28 [DEBUG] TCP connection to SSH ip/port failed: dial tcp: address [[2620:83:8008:161::17]]:22: missing port in address
...
and so on in a loop.

Logs after this PR

2025/10/13 23:09:33 packer-plugin-vsphere_v2.1.0-dev_x5.0_linux_amd64 plugin: 2025/10/13 23:09:33 VM IP acquired:
2025/10/13 23:09:33 packer-plugin-vsphere_v2.1.0-dev_x5.0_linux_amd64 plugin: 2025/10/13 23:09:33 VM IP acquired: 2620:83:8008:161::17
2025/10/13 23:09:33 packer-plugin-vsphere_v2.1.0-dev_x5.0_linux_amd64 plugin: 2025/10/13 23:09:33 VM IP is still the same: 2620:83:8008:161::17
...
2025/10/13 23:09:38 packer-plugin-vsphere_v2.1.0-dev_x5.0_linux_amd64 plugin: 2025/10/13 23:09:38 VM IP seems stable enough: 2620:83:8008:161::17
2025/10/13 23:09:38 ui: ==> vsphere-iso: Using SSH communicator to connect: 2620:83:8008:161::17
2025/10/13 23:09:38 packer-plugin-vsphere_v2.1.0-dev_x5.0_linux_amd64 plugin: 2025/10/13 23:09:38 [INFO] Waiting for SSH, up to timeout: 30m0s
2025/10/13 23:09:38 ui: ==> vsphere-iso: Waiting for SSH to become available...
2025/10/13 23:09:38 packer-plugin-vsphere_v2.1.0-dev_x5.0_linux_amd64 plugin: 2025/10/13 23:09:38 [INFO] Attempting SSH connection to [2620:83:8008:161::17]:22...
2025/10/13 23:09:38 packer-plugin-vsphere_v2.1.0-dev_x5.0_linux_amd64 plugin: 2025/10/13 23:09:38 [DEBUG] reconnecting to TCP connection for SSH
2025/10/13 23:09:38 packer-plugin-vsphere_v2.1.0-dev_x5.0_linux_amd64 plugin: 2025/10/13 23:09:38 [DEBUG] handshaking with SSH
2025/10/13 23:09:42 packer-plugin-vsphere_v2.1.0-dev_x5.0_linux_amd64 plugin: 2025/10/13 23:09:42 [DEBUG] SSH handshake err: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none password], no supported methods remain
2025/10/13 23:09:42 packer-plugin-vsphere_v2.1.0-dev_x5.0_linux_amd64 plugin: 2025/10/13 23:09:42 [DEBUG] Detected authentication error. Increasing handshake attempts.
...
2025/10/13 23:13:27 packer-plugin-vsphere_v2.1.0-dev_x5.0_linux_amd64 plugin: 2025/10/13 23:13:27 [INFO] Attempting SSH connection to [2620:83:8008:161::17]:22...
2025/10/13 23:13:27 packer-plugin-vsphere_v2.1.0-dev_x5.0_linux_amd64 plugin: 2025/10/13 23:13:27 [DEBUG] reconnecting to TCP connection for SSH
2025/10/13 23:13:27 packer-plugin-vsphere_v2.1.0-dev_x5.0_linux_amd64 plugin: 2025/10/13 23:13:27 [DEBUG] handshaking with SSH
2025/10/13 23:13:33 packer-plugin-vsphere_v2.1.0-dev_x5.0_linux_amd64 plugin: 2025/10/13 23:13:33 [DEBUG] handshake complete!
2025/10/13 23:13:33 packer-plugin-vsphere_v2.1.0-dev_x5.0_linux_amd64 plugin: 2025/10/13 23:13:33 [DEBUG] Opening new ssh session
2025/10/13 23:13:34 packer-plugin-vsphere_v2.1.0-dev_x5.0_linux_amd64 plugin: 2025/10/13 23:13:34 [INFO] agent forwarding enabled
2025/10/13 23:13:34 ui: ==> vsphere-iso: Connected to SSH!

@clarsen clarsen requested a review from a team as a code owner October 13, 2025 23:44
@hashicorp-cla-app
Copy link

hashicorp-cla-app bot commented Oct 13, 2025

CLA assistant check
All committers have signed the CLA.

@hashicorp-cla-app
Copy link

CLA assistant check

Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement

Learn more about why HashiCorp requires a CLA and what the CLA includes


Case Larsen seems not to be a GitHub user.
You need a GitHub account to be able to sign the CLA.
If you have already a GitHub account, please add the email address used for this commit to your account.

Have you signed the CLA already but the status is still pending? Recheck it.

@tenthirtyam tenthirtyam marked this pull request as draft October 14, 2025 00:20
@tenthirtyam
Copy link
Collaborator

Marking as draft for the time being.

@tenthirtyam tenthirtyam added this to the Backlog milestone Oct 14, 2025
@tenthirtyam tenthirtyam changed the title don't wrap IPv6 addresses in "[" and "]" because net.JoinHostPort does it [wip] don't wrap IPv6 addresses in "[" and "]" because net.JoinHostPort does it Oct 14, 2025
@tenthirtyam tenthirtyam requested a review from Copilot October 14, 2025 00:51
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a bug where IPv6 addresses were being double-wrapped in brackets, causing SSH connection failures. The code was manually wrapping IPv6 addresses in brackets, but Go's net.JoinHostPort function already handles this, resulting in malformed addresses like [[IPv6]]:port.

  • Removed manual IPv6 bracket wrapping logic
  • Added documentation explaining why the wrapping was removed
  • Fixed SSH communicator failures with IPv6 addresses

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@tenthirtyam tenthirtyam changed the title [wip] don't wrap IPv6 addresses in "[" and "]" because net.JoinHostPort does it [wip] fix: IPv6 addresses double-wrapped in brackets Oct 14, 2025
@tenthirtyam tenthirtyam force-pushed the fix-ipv6-ssh-communicator branch from cefa7e3 to bc8b0fb Compare October 14, 2025 03:39
@tenthirtyam
Copy link
Collaborator

tenthirtyam commented Oct 14, 2025

Marking as draft for the time being.

I've amended and addressed the above.

Copy link
Collaborator

@tenthirtyam tenthirtyam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tenthirtyam tenthirtyam changed the title [wip] fix: IPv6 addresses double-wrapped in brackets fix: IPv6 addresses double-wrapped in brackets Oct 14, 2025
@tenthirtyam tenthirtyam marked this pull request as ready for review October 14, 2025 03:40
@tenthirtyam tenthirtyam requested a review from kp2099 October 14, 2025 03:41
@tenthirtyam tenthirtyam modified the milestones: Backlog, v2.1.0 Oct 14, 2025
@clarsen
Copy link
Contributor Author

clarsen commented Oct 14, 2025

Marking as draft for the time being.

I've amended and addressed the above.

thanks for taking care of the code/commit comment issues.
I did sign the CLA with my primary github email and the email listed in the commit has been added to my profile as an alternate email...

@tenthirtyam
Copy link
Collaborator

thanks for taking care of the code/commit comment issues. I did sign the CLA with my primary github email and the email listed in the commit has been added to my profile as an alternate email...

You're welcome! @kp2099 will review this one along with a few others this week. Depending on the payload we may consider a minor patch for this issue and one other ahead of v2.1.0.

@tenthirtyam tenthirtyam force-pushed the fix-ipv6-ssh-communicator branch from bc8b0fb to 95a4d9c Compare November 17, 2025 16:03
@kp2099 kp2099 merged commit d198c80 into hashicorp:main Nov 19, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants