Generating SSH Keys
We strongly recommend using a SSH connection when interacting with GitHub. SSH Keys is a-identify trusted computers, without involving passwords. The steps below would walk you through generating a SSH key and then adding the public key to your GitHub account.
Tip: We recommend this regularly review your SSH keys list and revoke any, haven ' t been used in a while.
Step 1:check for SSH keys
First, we need to check for existing SSH keys on your computer. Open up your Terminal and type:
CD ~/.sshls-al# Lists the files in your. SSH directory
Check the directory listing to see if you have files named either id_rsa.pub
or id_dsa.pub
. If you don't have the either of those files go to Step 2. Otherwise, you can skip to step 3.
Step 2:generate a new SSH key
To generate a new SSH key, copy and paste the text below, making sure to substitute in your email. The default settings is preferred, so when you ' re asked to "Enter a file in which to save the key," "Just press ENTER to Continue.
Ssh-keygen-t rsa-c "[email protected]"# Creates a new SSH key, using the provided email as a label# Gen Erating public/private RSA key pair. # Enter file in which to save the key (/home/you/.ssh/id_rsa):
Next, you'll be asked to enter a passphrase.
Tip: We strongly recommend a very good, secure passphrase. For more information, see Working with SSH key passphrases.
[Type a passphrase] [Type passphrase again]
Which should give you something like this:
# Your identification have been saved in/home/you/.ssh/id_rsa. # Your Public key have been saved in/home/you/.ssh/id_rsa.pub. # The key fingerprint is:01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db [email protected]
Then add your new key to the ssh-agent:
Be careful " is not" # Agent pid 59566ssh-add ~/.ssh/id_rsa
Step 3:add your SSH key to GitHub
Run The following code to copy the key to your clipboard.
sudo apt-get install xclip# Downloads and installs Xclip. If you don't have the ' apt-get ', you might need to use another installer (like ' yum ')Xclip-sel clip < ~/.ssh/id_rsa.pu b# Copies The contents of the Id_rsa.pub file to your clipboard
Alternatively, using your favorite text editor, you can open the ~/.ssh/id_rsa.pub file and copy the contents of The file manually
Step 4:test everything out
To make sure everything are working, you'll now try Sshing to GitHub. When you have the asked to authenticate this action using your password, which is the passphrase you created Earlier.
Open up your Terminal and type:
ssh-t [email protected]# attempts to ssh to GitHub
It's possible that you'll see this error message:
... Agent admitted failure to sign using the-key.debug1:No more authentication methods to try. Permission denied (PublicKey).
This was a known problem with certain Linux distributions. For a possible resolution, see our help article.
Warning:
# The authenticity of host ' github.com (207.97.227.239) ' can ' t be established. # RSA Key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48. # is you sure-want to continue connecting (yes/no)?
Don ' t worry! This was supposed to happen. Verify that the fingerprint in your terminal matches the one we've provided up above, and then type "Yes."
username! You ' ve successfully authenticated, but GitHub does not# provide shell access.
If that username was yours, you ' ve successfully set up your SSH key! Don ' t worry about the "shell access" thing, and you don ' t want that anyway.
More details: https://help.github.com/articles/generating-ssh-keys