Use ssh in Git.


First of all, check if you have had public key by:

cd ~/.ssh


If you have foo and, it means that you aleardy have a private key and a public key. Repeat the following methods will overwritten the keys if they have the same name.

To generate ssh key, use the command below:

ssh-keygen -t rsa -C ""

Feel free to enter ENTER during the generation.


To check your public key (Note, id_rsa is the default name):

cat ~/.ssh/

Copy it and paste into GitHub's settings page in Account Settings->SSH Keys->Add SSH key.

Note: if you use this key to access to your remote server, then you can copy the content of your public key and paste it into the ~/.ssh/authorized_keys file.


To test it:

ssh -T