Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSH communicator fails when ssh_password contains "#" #170

Closed
hc-github-team-packer opened this issue Apr 9, 2024 · 1 comment
Closed

Comments

@hc-github-team-packer
Copy link

This issue was originally opened by @digitalqualms in hashicorp/packer#12904 and has been migrated to this repository. The original issue description is below.


Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

When filing a bug, please include the following headings if possible. Any
example text in this template can be deleted.

Overview of the Issue

When using the proxmox-iso, I was encountering SSH handshake error. It turned out that because my ssh_password value I was using contained the pound/hash symbol "#". It looks like this value isn't escaped properly.

Reproduction Steps

Create an HCL template that uses the ssh communicator. Set the ssh_password value to something that contain "#". Build fails with:

Packer version

1.9.4

Simplified Packer Template

source "proxmox-iso" "ubuntu22-04" {
  // Proxmox config
  iso_file       = "local:iso/ubuntu-22.04.2-live-server-amd64.iso"
  iso_checksum   = "none"
  proxmox_url    = "https:/proxmox:8006/api2/json"
  username       = ${var.pve_username
  token          = var.pve_token
  node           = "pve1"
  http_directory = "config"

  onboot             = true
  memory             = 8192
  ballooning_minimum = 4096
  cores              = 2
  cpu_type           = "host"
  os                 = "l26"
  bios               = "ovmf"
  scsi_controller    = "virtio-scsi-single"
  efi_config {
    efi_storage_pool  = "local-thin"
    efi_type          = "4m"
    pre_enrolled_keys = true
  }
  disks {
    disk_size    = "50G"
    storage_pool = "local-thin"
    type         = "scsi"
  }
  network_adapters {
    bridge   = "vmbr0"
    model    = "virtio"
    firewall = true
  }
  boot_command = [
    "c",
    "linux /casper/vmlinuz --- pv6.disable=1 autoinstall ds='nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/'",
    "<enter><wait>",
    "initrd /casper/initrd<enter><wait>",
    "boot<enter>"
  ]
  boot_wait            = "10s"
  ssh_username         = "myuser"
  ssh_password         = "abc-def#"
  ssh_timeout          = "120m"
  ssh_handshake_attempts = 10
  template_description = "Ubuntu 22.04, generated on ${timestamp()}"
  template_name        = "ubuntu-22.04"
  unmount_iso          = true
}

build {
  sources = ["source.proxmox-iso.ubuntu22-04"]
  provisioner "shell" {
    inline = [
      "while [ ! -f /var/lib/cloud/instance/boot-finished ]; do echo 'Waiting for cloud-init...'; sleep 1; done"
    ]
  }
}

Operating system and Environment details

Packer run from macOS 14.4.1 (23E224), arm64
Proxmox plugin: v1.1.7_x5.0_darwin_arm64
Connecting to Ubuntu 22.04

Log Fragments and crash.log files

02 19:50:12 [INFO] Attempting SSH connection to 192.168.0.97:22...
2024/04/02 19:50:12 packer-plugin-proxmox_v1.1.7_x5.0_darwin_arm64 plugin: 2024/04/02 19:50:12 [DEBUG] reconnecting to TCP connection for SSH
2024/04/02 19:50:12 packer-plugin-proxmox_v1.1.7_x5.0_darwin_arm64 plugin: 2024/04/02 19:50:12 [DEBUG] handshaking with SSH
2024/04/02 19:50:14 packer-plugin-proxmox_v1.1.7_x5.0_darwin_arm64 plugin: 2024/04/02 19:50:14 [DEBUG] SSH handshake err: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none password], no supported methods remain
2024/04/02 19:50:14 packer-plugin-proxmox_v1.1.7_x5.0_darwin_arm64 plugin: 2024/04/02 19:50:14 [DEBUG] Detected authentication error. Increasing handshake attempts.
2024/04/02 19:50:21 packer-plugin-proxmox_v1.1.7_x5.0_darwin_arm64 plugin: 2024/04/
==> proxmox-iso.ubuntu22-04: Error waiting for SSH: Packer experienced an authentication error when trying to connect via SSH. This can happen if your username/password are wrong. You may want to double-check your credentials as part of your debugging process. original error: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none password], no supported methods remain
@lbajolet-hashicorp
Copy link
Contributor

Too early to tell this is the root cause of the problem, I mislabeled the original issue, hence why this was automatically created.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants