Search code examples
amazon-web-servicesamazon-ec2amazon-elastic-beanstalk

Elastic Beanstalk ssh says it can't find my SSH key file


I'm trying to logon to an EBElastic Beanstalkinstance.

eb ssh

I then get the error:

ERROR: NotFoundError - The EB CLI cannot find your SSH key file for keyname "myName". Your SSH key file must be located in the .ssh folder in your home directory.

In the root directory of my project I have a directory:

.ssh

In it I've placed myName.pem and also just myName no extension.

-----BEGIN RSA PRIVATE KEY-----
abunchofcharacters...blahblah
-----END RSA PRIVATE KEY----

I'm not sure why this is not working. Any ideas as to why?


Solution

  • You need to put the key file in the .ssh directory beneath your home directory, not the root directory of your project.

    Linux

    On a linux based machine you can get to the right directory with

    cd ~/.ssh
    

    This is where you need to put your key file.

    Windows

    On a Windows machine, the directory you need to put the key file in will be something like

    C:\Users\[ACCOUNT NAME]\.ssh
    

    Swap [ACCOUNT NAME] out for whatever your Windows account is called.

    I would also highly recommend generating a new key pair and removing the existing one - the one you have has now probably been committed to version control, or is sat in the project root on your ELB instance. Both scenarios are a massive security risk.