DEV Community

Cover image for How to configure Git on Ubuntu and add ssh key to github
Kelly Carvalho
Kelly Carvalho

Posted on • Updated on


How to configure Git on Ubuntu and add ssh key to github

About me

Hello, Everyone. I’m a back-end developer. I like cats and roller skating, I'm crazy for challenges and I am always looking to learn something really new. I love to write and I intend to continue writing about different subjects here. This is my first post and I'm open to suggestions and if there's anything wrong you can signal.

Without further introductions let's get to the content.

It's not cool to needing to login every time that you have to push,actually you can solve it quite easily. You can just add your ssh key to github. Personally I use linux distribution Ubuntu as System Operator.


Installing Git and checking if it's working

Usually the Git is already installed on Ubuntu, but sometimes is necessary to install. You can use the following command to install it

~$ sudo apt install git

Enter fullscreen mode Exit fullscreen mode


You can make sure it's install by using the following command

~$ git
Enter fullscreen mode Exit fullscreen mode

If something like this comes up it means Git is already installed

Image description

It's important to configure your username and email for the commits from your user be recognized

Setting your user and email

~$ git config --global "Meu Nome"
~$ git config --global ""
Enter fullscreen mode Exit fullscreen mode

Now you can see your configuration

~$ git config --global
Meu Nome
~$ git config --global
Enter fullscreen mode Exit fullscreen mode

Generating ssh keys

~$ ssh-keygen -t ed25519 -C ""

Enter fullscreen mode Exit fullscreen mode

This command in addition to generating the public and private key using Ed25519 algorithm, it will return the path where your keys are, usually the path is /home/userLinux.


You shouldn't show the private key to anyone

After locating where the .ssh keys were generated, you will copy the content from text file with .pub extension. This is your public key.


Adding public ssh key to GitHub

Go to Settings on your GitHub profile

Image description

Section SSH and GPG keys

Image description

Click on Button "new SSH Key"

Image description

You can past your public key on text box and choose a title and it's ready! Git will not ask login anymore!

if you are starting now I hope this helps.

Thx 😃 cya...

Top comments (3)

ricardogithub84 profile image
Ricardo Rosa

Congrats, i love it!

mateusspp profile image
Mateus Patricio

This is great, I hope you make more of these!

daud99 profile image

@kellycarvalho keep the good work. :)

50 CLI Tools You Can't Live Without

>> Check out this classic DEV post <<