1) Generate your pair of SSH keys:
ssh-keygen -t rsa -b 4096 -C "<email>@example.com"
Add a passphrase is better. Here your pair of keys:
- private key: without extension (keep that secret only for you)
- public key : with extension .pub (for everybody)
See https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/ .
Give a common suffix name to your keys for example github_id_rsa
in your ~/.ssh/
folder.
2) Copy your SSH public key via keyboard to web interface:
sudo apt-get install xclip
cat ~/.ssh/github_id_rsa.pub | xclip -selection clipboard
at https://github.com/settings/keys. Give a name to your SSH public key.
3) Manage your ~/.ssh/config
if multiple pairs of SSH keys:
...
Host github.com
User <username>
IdentityFile ~/.ssh/github_id_rsa
...
4) Modify your config git:
Go to your git respository and do:
git remote set-url origin git@github.com:<username>/<repository.git>
5) Test your SSH connection and see your configuration:
$ ssh -T git@github.com
Hi <username>! You've successfully authenticated, but GitHub does not provide shell access
git config --list
6) Push:
You can now do git status, add, commit and push without typing password and using SSH keys authentication (and type your passphrase kept by SSH agent if you have that).
References: