GitHub
SSH key
Generate an SSH key for my Linux virtual machine
1. Check for SSH key
$ ls -al ~/.ssh
I didn't have a key yet.
2. Generate one
$ ssh-keygen -t rsa -b 4096 -C "my_email@gmail.com"
Enter my password
3. Add key to ssh-agent
$ eval "($ssh-agent -s)"
$ ssh-add ~/.ssh/id_rsa
An explanation of ssh-agent given by wikipedia:
ssh-agentcreates a socket and then checks the connections fromssh. Everyone who is able to connect to this socket also has access to thessh-agent. The permissions are set as in a usual Linux or Unix system. When the agent starts, it creates a new directory in/tmpwith restrictive permissions. The socket is located in the folder.
4. Add SSH key to GitHub account
$ sudo cat ~/.ssh/id_rsa.pub
Then I copied into Github/setting/SSH/Add Key under my Github account.
5. Test for connection
$ ssh -T git@github.com
Note that I don't have to change the above code to run the test.
6. How to use it?
One of the problem I encounter is that I don't know what to do after I set everything. Later I realized that I was still using https protocol to git add and git push things instead of doing it via SSH.
The idea is simple: re-pull the repo using SSH protocol:
$ git pull git@github.com:jaspereclipse/stat243.git
I only need to input my password once and for all.