I am creating servers on AWS using Terraform on a Windows machine and that is working great. When they are created I want to install docker on them. However, after creating them, the SSH connection from Terraform fails (manually using Linux subsystem or Putty I can login just fine).
Excerpt from terraform script:
resource "aws_instance" "worker-01" {
ami = "ami-1b2bb774"
instance_type = "t2.medium"
subnet_id = "${data.aws_subnet.public.id}"
key_name = "deployer-key"
security_groups = [
"${data.aws_security_group.ssh-access.id}"
]
tags {
Name = "worker-01"
}
connection {
user = "ec2-user"
}
provisioner "remote-exec" {
inline = [
// Install all updates
"sudo yum update -y",
// Install docker and add user to docker group
"sudo yum install docker -y",
"sudo service docker start",
"sudo usermod -a -G docker ec2-user"
]
}
}
The error message is very clear: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none], no supported methods remain
. Apparently the identity is not loaded in an ssh agent. Here is the catch: I have pageant running, with my identity loaded! Or rather, the KeeAgent plugin in KeePass is acting on behalf of it and has loaded the identity into pageant.
This works for any other SSH connection, but now it fails. Is that because of the username or is it something else that I am missing? If it is the username, then is there some way to tell KeeAgent / pageant that it should use my identity also for ec2-user? I know it should just try all identities, but no idea why it doesn't.
PS: I just realised I am running all of this in a normal command prompt. Maybe that doesn't have access to pageant by default? Anyone have an idea about this?