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.

Ubuntu

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

Git

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 user.name "Meu Nome"
~$ git config --global user.email "meuemail@email.com"


Enter fullscreen mode Exit fullscreen mode

Now you can see your configuration



~$ git config --global user.name
Meu Nome
~$ git config --global user.email
meuemail@email.com


Enter fullscreen mode Exit fullscreen mode

Generating ssh keys



~$ ssh-keygen -t ed25519 -C "your_email@example.com"




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.

Warning

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.

GitHub

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)

Collapse
 
ricardogithub84 profile image
Ricardo Rosa

Congrats, i love it!

Collapse
 
mateusspp profile image
Mateus Patricio

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

Collapse
 
daud99 profile image
daud99

@kellycarvalho keep the good work. :)