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

Can't ssh into a VM with any key #93

Open
screwyy opened this issue Jul 14, 2023 · 0 comments
Open

Can't ssh into a VM with any key #93

screwyy opened this issue Jul 14, 2023 · 0 comments

Comments

@screwyy
Copy link

screwyy commented Jul 14, 2023

Hello,

Packer version: 1.9.1
plugin version: 0.4.0

I'm not using the latest version of the plugin because I want to specify the network ID in order to test ssh to the VM.
By default packer creates the VM in 172.16.0.0/16 network and it's not good because I also have a network like that from where I run packer and it complicates the testing of SSH to it with peering/routes/security groups etc.

I am trying to create a new Image with packer based on Rocky 9.0 but packer can't ssh into it, while I am able to use the same key and before it destroys the VM I can connect to it
This is my code:

cat ~/workspaces/golden_image/image.json.pkr.hcl
source "huaweicloud-ecs" "ecs" {
  access_key       = "***"
  auth_url         = "https://iam.eu-west-0.prod-cloud-ocb.orange-business.com"
  flavor           = "s6.medium.2"
  image_name       = "Rocky-90_golden_0.0.1"
  networks         = ["031ef2ca-cc74-48a1-99cc-38b124441f91"]
  project_name     = "eu-west-0"
  region           = "eu-west-0"
  secret_key       = "***"
  security_groups  = ["ebc8291d-5368-4552-a65a-5bdd0b22f057"]  # this is the default SG
  source_image     = "7f85e7c0-b63a-4868-a273-0d6209c13d67"
  ssh_ip_version   = "4"
  ssh_username     = "cloud"
}

build {
  sources = ["source.huaweicloud-ecs.ecs"]

  provisioner "shell" {
    inline = ["sudo yum update -y; sudo sed -i -e 's/.*rocky-90-golden-1/%LOCALIPV4%  %LOCALHOSTNAME%.malima.internal %LOCALHOSTNAME%/' /etc/hosts"]
  }
}

This is the output:

The configuration is valid.
Debug mode enabled. Builds will not be parallelized.
huaweicloud-ecs.ecs: output will be in this color.
==> huaweicloud-ecs.ecs: Loading available zones ...
    huaweicloud-ecs.ecs: Available zones: eu-west-0a eu-west-0b eu-west-0c
    huaweicloud-ecs.ecs: Select eu-west-0b as the available zone
==> huaweicloud-ecs.ecs: Loading flavor: s6.medium.2
    huaweicloud-ecs.ecs: Verified flavor. ID: s6.medium.2
==> huaweicloud-ecs.ecs: Creating temporary keypair: packer_64b15507-5ae7-8a79-ec0e-084c43950b3c ...
==> huaweicloud-ecs.ecs: Created temporary keypair: packer_64b15507-5ae7-8a79-ec0e-084c43950b3c
    huaweicloud-ecs.ecs: Saving key for debug purposes: ecs_ecs.pem
==> huaweicloud-ecs.ecs: Creating volume...
==> huaweicloud-ecs.ecs: Waiting for volume packer_64b15507-41e6-a49b-2967-783b91db0be8 (volume id: 4da3e63b-06d1-4598-85bd-4700c936f75c) to become available...
    huaweicloud-ecs.ecs: Volume ID: 4da3e63b-06d1-4598-85bd-4700c936f75c
==> huaweicloud-ecs.ecs: Launching server in az:eu-west-0b ...
    huaweicloud-ecs.ecs: Server ID: 8b8fc1e8-338c-4840-885d-f107d86579ef
==> huaweicloud-ecs.ecs: Waiting for server to become ready...
==> huaweicloud-ecs.ecs: Using ssh communicator to connect: 172.16.100.236
==> huaweicloud-ecs.ecs: Waiting for SSH to become available...
==> huaweicloud-ecs.ecs: 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 publickey], no supported methods remain
==> huaweicloud-ecs.ecs: Terminating the source server: 8b8fc1e8-338c-4840-885d-f107d86579ef ...
==> huaweicloud-ecs.ecs: Deleting volume: 4da3e63b-06d1-4598-85bd-4700c936f75c ...
==> huaweicloud-ecs.ecs: Deleting temporary keypair: packer_64b15507-5ae7-8a79-ec0e-084c43950b3c ...
Build 'huaweicloud-ecs.ecs' errored after 2 minutes 2 seconds: 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 publickey], no supported methods remain
==> Wait completed after 2 minutes 2 seconds
==> Some builds didn't complete successfully and had errors:
--> huaweicloud-ecs.ecs: 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 publickey], no supported methods remain
==> Builds finished but no artifacts were created.
ssh [email protected] -i ecs_ecs.pem
Warning: Permanently added '172.16.100.236' (ECDSA) to the list of known hosts.
[cloud@rocky-90-golden-0 ~]$ uname -a
Linux rocky-90-golden-0.0.1 5.14.0-70.22.1.el9_0.x86_64 #1 SMP PREEMPT Tue Aug 9 19:45:51 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
[cloud@rocky-90-golden-0 ~]$ uptime
 13:57:00 up 0 min,  1 user,  load average: 1.71, 0.50, 0.17

If I remove the networks and upgrade the plugin I have the same issue (but can't test anymore)

The configuration is valid.
Debug mode enabled. Builds will not be parallelized.
huaweicloud-ecs.ecs: output will be in this color.
==> huaweicloud-ecs.ecs: Loading availability zones...
    huaweicloud-ecs.ecs: Availability zones: eu-west-0a eu-west-0b eu-west-0c
    huaweicloud-ecs.ecs: Select eu-west-0b as the availability zone
==> huaweicloud-ecs.ecs: Loading flavor: s6.medium.2
==> huaweicloud-ecs.ecs: Creating temporary keypair: packer_64b156c8-5daf-ff8b-0907-c3a31c80e7f3...
==> huaweicloud-ecs.ecs: Created temporary keypair: packer_64b156c8-5daf-ff8b-0907-c3a31c80e7f3
    huaweicloud-ecs.ecs: Saving key for debug purposes: ecs_ecs.pem
==> huaweicloud-ecs.ecs: Creating temporary VPC...
    huaweicloud-ecs.ecs: temporary VPC ID: 6701fee5-39d6-4e68-a480-38665a9289e4
==> huaweicloud-ecs.ecs: Creating temporary subnet...
    huaweicloud-ecs.ecs: temporary subnet ID: e65707c2-82e8-40b0-8366-9824bfa07174
    huaweicloud-ecs.ecs: the [ebc8291d-5368-4552-a65a-5bdd0b22f057] security groups will be used ...
==> huaweicloud-ecs.ecs: Launching server in AZ eu-west-0b...
    huaweicloud-ecs.ecs: Waiting for server to become ready...
    huaweicloud-ecs.ecs: Server ID: 7a97fdf9-c13a-4caa-b67a-e2b3bf701783
==> huaweicloud-ecs.ecs: Using SSH communicator to connect: 172.16.0.112
==> huaweicloud-ecs.ecs: Waiting for SSH to become available...
==> huaweicloud-ecs.ecs: Timeout waiting for SSH.
==> huaweicloud-ecs.ecs: Detacheing the volume...
==> huaweicloud-ecs.ecs: Terminating the source server: 7a97fdf9-c13a-4caa-b67a-e2b3bf701783...
==> huaweicloud-ecs.ecs: Deleting temporary subnet: e65707c2-82e8-40b0-8366-9824bfa07174...
==> huaweicloud-ecs.ecs: Deleting temporary VPC: 6701fee5-39d6-4e68-a480-38665a9289e4...
==> huaweicloud-ecs.ecs: Deleting temporary keypair: packer_64b156c8-5daf-ff8b-0907-c3a31c80e7f3 ...
Build 'huaweicloud-ecs.ecs' errored after 6 minutes 24 seconds: Timeout waiting for SSH.

Please advise on how to move forward.

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

1 participant