Connect over ssh using a .pem file

danielrvt picture danielrvt · Dec 2, 2015 · Viewed 105.2k times · Source

I would like to know how to connect over ssh using a .pem file to any server.

Currently I'm executing the following command:

ssh [email protected]

What option should I use?

Answer

legoscia picture legoscia · Dec 2, 2015

Use the -i option:

ssh -i mykey.pem [email protected]

As noted in this answer, this file needs to have correct permissions set. The ssh man page says:

ssh will simply ignore a private key file if it is accessible by others.

You can change the permissions with this command:

chmod go= mykey.pem

That is, set permissions for group and others equal to the empty list of permissions.