ansible-community / ansible-community/molecule-plugins
SSH into EC2 instance fails with permission error
- Dominant language
- Python
- Stars
- 164
- Forks
- 113
- Avg merge
- 4d 20h
- Merged PRs (30d)
- 1
Description
Dear Folks,
I am new to molecule and I am trying my hand at using the ec2 driver plugin.
I am able to create the EC2 instance and the required security group but have not been able to successfully login into the machine.
I keep getting the following error message when running `molecule create`.
```fatal: [molecule-instance]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: Waiting on browser...\nBrowser step completed successfully.\nerror: Could not resolve: REDACTED: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).", "unreachable": true}```
I have only made minimal customizations such as disabling the creation of a public IP so that I may use a private IP instead.
I have pasted the settings I have in my `molecule.yml` file below:
```yaml
---
dependency:
name: galaxy
driver:
name: ec2
platforms:
- name: molecule-instance
assign_public_ip: false
connection_options:
ansible_python_interpereter: /usr/bin/python
image_name: ""
image_owner: [""]
instance_type: t3.micro
region: ""
ssh_user: ec2-user
vpc_id: ""
vpc_subnet_id: ""
tags:
Name: molecule-instance
provisioner:
name: ansible
verifier:
name: ansible
```
I know that this issue probably relates more to the Linux AMI I am using which is a slightly customized version of Amazon Linux 2 but I hope you may be able to shed some light.
I tried both the `ec2` and `cloud-init` for the `key_inject_methods` field but the SSH login does not work.
I look forward to your reply.
Many thanks.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the molecule.yml settings for the EC2 driver, especially assign_public_ip, connection_options, ssh_user, and the tried key_inject_methods values. Compare the ec2 and cloud-init login paths against the SSH permission error; the issue is resolved when molecule create can connect to the customized Amazon Linux 2 instance.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, linux
- Domain
- cloud
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100