Blog

Thoughts from my daily grind

Install and Setup Git for Github - Ubuntu 20.04

Posted by Ziyan Junaideen |Published: 05 September 2020 |Category: Linux
Default Upload |

One of the first utilities a developer will install in his computer is Git. In case you don't know, Git is a distributed version control system used for managing code in software development.

I just upgraded my laptop from Ubuntu 18.04 to Ubuntu 20.04 (fresh installation) and figured Git isn't coming preinstalled.

Installing Git on your Ubuntu box is simple. In the terminal run the following commands.

sudo apt update
sudo apt install git

While you can get away with this, if you are going to commit code to a repository, you should also configure your name and email. I use the name and email as in my Github profile. That way people know its me.

git config --global user.name "<Your Name>"
git config --global user.email "<Your Email>"

You may think you are done. But that is not it. Now you need to generate your Public/Private Keys for SSH. Run ssh-keygen this will start the process to generate keys. Its like a wizard, except in a terminal.

ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/ziyan/.ssh/id_rsa):

If you want you can enter a password. I usually do, that way even if some one has access to my machine, they won't push any thing fishy to the repositories.

Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 

Once you continue with or without the password you will be given a summary. Basically this is where your SSH keys would be stored.

Your identification has been saved in /home/ziyan/.ssh/id_rsa
Your public key has been saved in /home/ziyan/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:64DsdsdFDGd1xVFDbGXdDFsqIu5KMKFV4w+ahdffsVBfDj1I

ziyan@ziyan-hp
The key's randomart image is:
+---[RSA 3072]----+
|    o     ...+.. |
|     + o .  . Eo |
|   +  = o . .  o=|
|  o  * + +  . .=o|
|  . =   S    ....|
|     o =.o. o o. |
|      =.o. . = ..|
|     o +.o  . o .|
|     .+o+ .. .   |
+----[SHA256]-----+

Now we need to copy the public key, that is the id_rsa.pub and add it to your Github profile. While you are at it, you might as well remove the old one. xclip is a neat terminal tool that can help you with it.

sudo apt install xclip
cat ~/.ssh/id_rsa.pub | xclip -selection clipboard

Now the contents of id_rsa.pub (public key) is not in your clipboard. Head off to Githb and paste the code there to add a new entry to allowed keys.

Tags
About the Author

Ziyan Junaideen -

Ziyan is an expert Ruby on Rails web developer with 8 years of experience specializing in SaaS applications. He spends his free time he writes blogs, drawing on his iPad, shoots photos.

Comments