Created
April 29, 2015 18:40
-
-
Save rigobertocontreras/863dc63fec35e54dadb1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OpenSSH is particular with how keys are stored and used. Do the following: | |
1) Create and ensure your ~/.ssh directory has the correct permissions: | |
$ mkdir ~/.ssh | |
$ chmod 700 ~/.ssh | |
$ ls -ld ~/.ssh | |
drwx------ 2 username group 4096 Jun 10 19:47 /Users/username/.ssh | |
2) Copy the private key (in your case the .pem file) to the ~/.ssh directory and set the appropriate permissions: | |
$ cp ~/Downloads/filename.pem ~/.ssh/filename.pem | |
$ chmod 600 ~/.ssh/filename.pem | |
3) Since you are using OS X make sure Finder didn't set any unnecessary extended attributes and remove them: | |
$ xattr -l ~/.ssh/filename.pem | |
$ xattr -d <attr_name> ~/.ssh/filename.pem | |
4) Now you can try using the key: | |
$ ssh -i ~/.ssh/filename.pem [email protected] | |
5) Once you have verified this work you can use the ~/.ssh/config file to make connecting to the remote host easier, rather than having to manually specify the identity file to use. For example: | |
Host remote.hostname.com | |
User username | |
IdentityFile ~/.ssh/filename.pem | |
From this point forward you can just run ssh remote.hostname.com to connect to your remote server. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment