[ ssh ] github SSH id_rsa


This will be used only when we clone the repository from the SSH.

If we cloned from HTTPS, SSH key will not be used.


1. generate the key using ssh-keygen

$ ssh-keygen -t rsa -b 4096 -C "GitHub-Key"
Generating public/private rsa key pair.
Enter file in which to save the key (/home/dsin/.ssh/id_rsa): githubnewtestkey
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in githubnewtestkey.
Your public key has been saved in githubnewtestkey.pub.
The key fingerprint is:
XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX phong.ek@gmail.com
The key's randomart image is:
+--[ RSA 4096]----+
|X XX XX X |
| X XXX X X |
| XXXX X X |
| X X X |
| X X X |
| X |
| |

Two files will be generated


NOTE : The filename should be generated from ssh-keygen command, and cannot manually rename.

If you want to change the name, create a new one.

2. add ssh key to account

Copies the contents of the id_rsa.pub file to your clipboard

xclip -sel clip < ~/.ssh/githubnewtestkey.pub

Go to github website > setting
– remove all deprecated key
– click add SSH key

NOTE : behide the scene I think github append our public key to `~/.ssh/authorized_keys` file

cat identity.pub >> ~/.ssh/authorized_keys

3. Any ssh client need “private key + passphrase” to login.
When you execute git push command they will ask for the passphrase using the alert window below.

[soucecode language=”text”]An application wants access to the private key ‘phong.ek@gmail.com’, but it is locked[/sourcecode]
Screenshot from 2015-10-14 17:12:31

If you do not want to enter passphrase every time, add your passphrase to the ssh-agent

$ ssh-add ~/.ssh/githubnewtestkey
Enter passphrase for /home/dsin/.ssh/githubnewtestkey:
Identity added: /home/dsin/.ssh/githubnewtestkey (/home/dsin/.ssh/githubnewtestkey)

We can listed all the passpharse added

$ ssh-add -l

4. Test the connection

ssh -T git@github.com

Authenticated !

Hi dsin! You've successfully authenticated, but GitHub does not provide shell access.

5. List Privilege

ssh -v git@github.com

ref: official github help

Small Tips on switch the default private key


host github.com
HostName github.com
IdentityFile ~/.ssh/GitHub-Dsin-Windows-Key
User git

ref : http://superuser.com/questions/232373/how-to-tell-git-which-private-key-to-use


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s