27

Added an RSA deploy key to my private github repo, but when I add it to my OpsWorks rails app (paste public key into the "Repository SSH Key" field), and try to save, I get the error message "Please provide a valid SSH key".

Key was generated using ssh-keygen defaults (RSA 2048, no passphrase).

Not sure what else could be amiss.

cdn
  • 1,422
  • 11
  • 12

3 Answers3

45

Ah ... silly me.

AWS OpsWorks is asking for the key that will be deployed to the app server, so it needs the private key (including -----BEGIN RSA PRIVATE KEY----- and -----END RSA PRIVATE KEY----- delimiters).

The github deploy key, obviously, is the public key.

cdn
  • 1,422
  • 11
  • 12
  • What are the steps you took to resolve this? I'm trying to achieve the same thing right now, but I'm going in circles. OpsWorks wants the private key, Github wants the public key, but I'm not sure how to go about generating either using OpsWorks. – AJB Sep 14 '14 at 23:35
  • yeah this is insane. i can't SSH into my opsworks ec2 instance. i've granted my admin user all sorts of privileges but i keep getting permission denied (publicly)... hoping this gets bumped so someone else can chime in with some help here. i went through a lot of circles on AWS documentation and still can't login – kinghenry14 Oct 22 '14 at 01:57
  • 11
    I faced the same problem with a private key generated on my mac (mojave 10.14.4). ssh-keygen generated the private key with the format -----BEGIN OPENSSH PRIVATE KEY----- instead 'RSA' wich was not accepted by AWS OpsWorks. In that case you can run the ssh-keygen command with the '-m PEM' option. – benedikt May 14 '19 at 13:50
3

AWS Opsworks needs the private key instead of the public. If the field returns:

Please provide a valid SSH key

You probably copy pasted the public key. After you've generated a SSH key (for more information about this see: https://help.github.com/articles/generating-ssh-keys/ )

You want to copy the private key by entering the following command in your terminal.

pbcopy < ~/.ssh/id_rsa

And then paste the private key in the Repository SSH field. Please note that you need to assign the public key to the repository.

http://docs.aws.amazon.com/opsworks/latest/userguide/workingapps-deploykeys.html

Hartsema
  • 31
  • 2
2

I solved this problem by following these steps:

  1. ssh-keygen -t rsa -C "example@example.com" -m PEM
  2. When you get to this step Enter passphrase (empty for no passphrase): just press return to skip passphrase setup. Otherwise, AWS won't able to clone your app repo
ruslan
  • 909
  • 6
  • 7