Ansible install failing on a staging EC2 Ubuntu instance

While running the ansible deployment for my staging server (an AWS EC2 ubuntu server), an error is happing during < TASK [users : Add SSH keys] >. The staging server has the private shared key for the .pem file that was generated while creating the instance for the ubuntu user (which I have made the admin_user). The failure seems to occurring with the /home/web/.ssh/authorized_keys file on the staging server. Do I need to modify this file on the staging server? Please let me know if there is additional information or errors that I should provide to help troubleshoot this.

How about the actual error/log output?

Hi Scott,

Thanks for responding so quickly. Do you mean the output from “ansible-playbook server.yml -e env=staging -vvvv”?

ie:

invalid key specified: -----BEGIN RSA PRIVATE KEY-----
failed: [stg.mydomain.com] (item=({u’name’: u’web’, u’groups’: [u’www-data’]}, u’-----BEGIN RSA PRIVATE KEY-----\r\ …key…r\n-----END RSA PRIVATE KEY-----"]}

invalid key specified: -----BEGIN RSA PRIVATE KEY-----
failed: [stg.mydomain.com] (item=({u’name’: u’ubuntu’, u’groups’: [u’sudo’]}, u’-----BEGIN RSA PRIVATE KEY-----\r…key…----END RSA PRIVATE KEY-----’)) => {“failed”: true, “item”: [{“groups”: [“sudo”], “name”: “ubuntu”}, "-- etc etc…

< NO MORE HOSTS LEFT >

[WARNING]: Could not create retry file ‘server.retry’. [Errno 2] No
such file or directory: ‘’

localhost : ok=0 changed=0 unreachable=0 failed=0
stg.mydomain.com : ok=30 changed=1 unreachable=0 failed=1

Thanks,
Ben

I did not include all of the ssh private key code in there. But I think it may have to do with local ssh keys on the EC2 Ubuntu server. Not entirely sure though.

The users feature only take SSH public keys. Our docs have more info on this: https://roots.io/trellis/docs/ssh-keys/

You were trying to specify private keys in there which won’t work.

2 Likes

Thanks Scott,

That worked like a charm. I generated a new public key from the private and pointed the admin_user to that. Server is provisioned and deployed!

Cheers from a fellow Torontonian,
Ben

2 Likes