
Programming
Setting Up Git/Github on Ubuntu In Five Minutes
Contents
1: Install Git
sudo apt-get install git-core git-doc
2: Configure Git
Bare minimum:
git config --global user.name "Firstname Lastname" git config --global user.email ""
Enable colors when outputting to terminal:
git config --global color.ui true
These settings are saved in ~/.gitconfig
.
3: Generate Cryptographic Keys
Create an RSA public/private key pair in the ~/.ssh/
directory. Be sure to use a passphrase.
ssh-keygen -t rsa -C "" -f ~/.ssh/git_rsa
This generates a private key in ~/.ssh/git_rsa
and the corresponding public key in ~/.ssh/git_rsa.pub
4: Add Public Key To Github
Copy all contents of ~/.ssh/git_rsa.pub
and add it to your Github profile.
$ cat ~/.ssh/git_rsa.pub ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDJCqSW4MyOESvnNL6Xjc9jQ3Vvj+yZSqD+HB5Dcbewc3vKpUISaC4mnUetN2B0Xn5QUOVTwdfDti+N+uMHod5VTeDPN7jNdbA/b/Vjo+C+hdJ8tissJDaCSQ29Wluhlogoe/4H3uSWmwKvMkgnK6DK3rXBKdy/T6Xeb8iFlxK5LLUt1B5nv9wxOGlhLd6ul5VeVGZKYxdwRLRkWE1w+ffEnfhJualOOZrW71up2EYl/FnmOMCMA7oKRyje+uQ2XSai220MlMwFH/VSOFskEM9dmilRxtFv27cq1vasiAIloKwFP8uYh42P4m3FPbWMulNXZvA3F4YsDfTBfDzQ3SUt myemail@gmail.com
5: Tell SSH to Use The New Key
Git uses the ssh application to connect to Github. By default, ssh only tries to use the private key in ~/.ssh/id_rsa
. We must tell it to also consider ~/.ssh/git_rsa
for SSH authentication.
$ ssh-add ~/.ssh/git_rsa
This command requires that the ssh-agent daemon is running. If you can’t use ssh-agent, create the file ~/.ssh/config
and add:
Host github.com User git IdentityFile ~/.ssh/git_rsa
6: Test Connection To Github
$ ssh -T git@github.com Hi <user>! You've successfully authenticated, but GitHub does not provide shell access.
7: Clone a Repository And Start Coding
$ git clone git@github.com:username/myrepo.git
Awesome!
Thank you for this post.