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 is disable on v2.2 images #1

Closed
Reregistered opened this issue May 3, 2024 · 6 comments
Closed

SSH is disable on v2.2 images #1

Reregistered opened this issue May 3, 2024 · 6 comments

Comments

@Reregistered
Copy link

Reregistered commented May 3, 2024

I'm trying to create a custom AMI based on the runs-on-v2.2-ubuntu22-full-x64 image, however SSH seems to be disabled.

I can successfully connect to instances based on runs-on-ubuntu22-full-x64 & runs-on-v2-ubuntu22-full-x64-20240324.2-1711611308

@crohr
Copy link
Contributor

crohr commented May 3, 2024

Hello, please see https://runs-on.com/reference/building-custom-ami-with-packer/ for instructions. I’ll add the link in this repo README.

@Reregistered
Copy link
Author

Reregistered commented May 3, 2024

@crohr - I've followed the instructions. The issue is, with the latest AMI's packer cannot connect over SSH.
To investigate the issue I've manually created instances based off of

runs-on-ubuntu22-full-x64
runs-on-v2-ubuntu22-full-x64-20240324.2-1711611308
runs-on-v2.2-ubuntu22-full-x64-202404272106

The first two are working with my packer config. The last fails at establishing an ssh connection.
The first two I can ssh into, the third gives Connection refused

@crohr
Copy link
Contributor

crohr commented May 3, 2024

@Reregistered are you sure you have declared the user-data file with the starting of the SSH daemon? Can you share the relevant parts of your packer template?

@Reregistered
Copy link
Author

Reregistered commented May 3, 2024

@crohr - This configuration works

packer {
  required_plugins {
    amazon = {
      source  = "github.com/hashicorp/amazon"
      version = "~> 1"
    }
  }
}
variable "subnet_id" {
  type    = string
}

variable "region" {
  type = string
}

variable "ami_prefix" {
  type = string
}

data "amazon-ami" "runs-on-ami" {
  filters = {
    name = "runs-on-v2-ubuntu22-full-x64-*"
    root-device-type = "ebs"
    virtualization-type = "hvm"
  }
  most_recent = true
  owners      = ["135269210855"]
  region      = "${var.region}"
}

source "amazon-ebs" "build-ebs" {
  ami_name      = "${var.ami_prefix}-runs-on-${formatdate("YYYY-MM-DD-hhmmss", timestamp())}"
  instance_type = "t3.small"
  region        = "${var.region}"
  subnet_id     = "${var.subnet_id}"
  source_ami    = "${data.amazon-ami.runs-on-ami.id}"
  ssh_username  = "ubuntu"
  user_data_file = "./user_data.sh"
  temporary_key_pair_type = "ed25519"
}

build {
  sources = ["source.amazon-ebs.build-ebs"]

  provisioner "shell" {
    script = "./provision.sh"
  }
}
image

While this configuration does not

packer {
  required_plugins {
    amazon = {
      source  = "github.com/hashicorp/amazon"
      version = "~> 1"
    }
  }
}
variable "subnet_id" {
  type    = string
}

variable "region" {
  type = string
}

variable "ami_prefix" {
  type = string
}

data "amazon-ami" "runs-on-ami" {
  filters = {
    name = "runs-on-v2.2-ubuntu22-full-x64-*"
    root-device-type = "ebs"
    virtualization-type = "hvm"
  }
  most_recent = true
  owners      = ["135269210855"]
  region      = "${var.region}"
}

source "amazon-ebs" "build-ebs" {
  ami_name      = "${var.ami_prefix}-runs-on-${formatdate("YYYY-MM-DD-hhmmss", timestamp())}"
  instance_type = "t3.small"
  region        = "${var.region}"
  subnet_id     = "${var.subnet_id}"
  source_ami    = "${data.amazon-ami.runs-on-ami.id}"
  ssh_username  = "ubuntu"
  user_data_file = "./user_data.sh"
  temporary_key_pair_type = "ed25519"
}

build {
  sources = ["source.amazon-ebs.build-ebs"]

  provisioner "shell" {
    script = "./provision.sh"
  }
}
image

The difference being the AMI in use.

To investigate, I manually created EC2 instances based off of the two AMI's. In the first case, I could establish an SSH connection, in the second I received Connection refused

image

at that point I opened the issue.

@crohr
Copy link
Contributor

crohr commented May 3, 2024

@Reregistered you are correct, for x64 it doesn't work. I had only tested with arm64. Will have a look and let you know when this is fixed.

@Reregistered
Copy link
Author

@crohr - I've tested again and the issue seems resolved. Thank you.,

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