How to Add an SSH key to Your GitHub or GitLab Account

Ilyas Hamadouche
The Startup
Published in
Jun 21, 2020

This guide shows you how to add an SSH key if you prefer to use Git over SSH instead of HTTP.

On your Linux/Mac machine, open the terminal and generate an SSH public key:

ssh-keygen -t rsa

Add your SSH key to GitHub/GitLab:

cat ~/.ssh/id_rsa.pub

Copy the public key and paste it into

Add your SSH key to terminal:

ssh-add ~/.ssh/id_rsa

(Optional) For private servers, add your GitHub/GitLab server to known hosts:

ssh-keyscan -H git.my-company.com >> ~/.ssh/known_hosts

About me

I am Ilyas Hamadouche, a Senior Software Engineer at Mbition. I am interested in automotive software, embedded systems, and computer vision. Follow me on Twitter and LinkedIn.

--

--