By Matias Herranz
While collaborating with others on several projects, I noticed there were a variety of issues that arose when generating and setting up the public keys, as well as issues with configuring the access to GIT repositories. These issues usually give people a bit of a tough time.
When it comes to recurring problems, there is nothing better suited than a little reference tutorial to help blaze the trail. So, let’s get started!
By Matias Herranz
While collaborating with several projects, I noticed issues when generating and setting up the public keys as well as configuring the access to GIT repositories. These usually gives people a bit of a harsh time.
When it comes to recurring problems there is nothing better suited than a little reference tutorial to blaze the trail. So, let’s get started!
#1: Generate your SSH key-pair and set it up
Step #1: Check to make sure you don’t already have a key pair
Open a terminal and run the following command:
1 |
cd ~/.ssh |
Check the directory listing to see if you have a file named either id_rsa.pub or id_dsa.pub. If you don’t have either of those files, go to step two. Otherwise, you already have an existing keypair, and you can skip to step three.
Step #2: Generate new SSH keys
To generate a new SSH key, enter the code below in the terminal. We want the default settings so when you’re asked to enter a file in which to save the key, just press enter.
1 |
$ ssh-keygen -t rsa -C “[email protected]” |
Now you need to enter a passphrase.
1 |
Enter passphrase (empty for no passphrase): [Type a passphrase] |
Which should give you something like this:
1 |
Your identification has been saved in /Users/you/.ssh/id_rsa. |
Step #3: Add your SSH key to GitLab
1. Go to your account settings.
2. Now go to the SSH keys section.
3. Click “Add SSH key.”
4. Give it a title you like (in the “Title” field) and paste your public key in the bigger “Key” field.
5. Click “Add key” and you will be done with loading the SSH public key in GitLab!
Step #4: Check to make sure everything worked
Now we should have the key pair generated and set up locally and the public key loaded in GitLab. Let’s make sure this is the case and that everything went fine.
To achieve such certainty, run the following command:
1 |
$ ssh -T [email protected] |
If everything went well, you should see an output like this:
1 |
$ ssh -T [email protected] |
#2: Some extra hints
Now we have the keys and our GitLab repo set up and ready to work. Now you should be able to clone, push/pull, and do all sorts of things with your GIT repos without being prompted for your username and password. If GIT, after making a command, asks you for your username or password, it means something went wrong at some point.
Go back and make sure you didn’t miss any steps or ask someone for help.
Done with this and want to learn some new tricks? Take a look at this link!
Hope this saves you time and frustrations in the near future!
Matias Herranz is as a Python Developer for Santex. He is a Computer Science and Open Source software enthusiast. He has professional experience on Python/Django web app development and also in mobile apps for iPhone/Android. He is a team player who enjoys and finds it rewarding to share the things he learns, either through conferences and lectures, or through day-to-day communication with his coworkers.
Hello There. I found your blog using msn. This is a very
well written article. I will be sure to bookmark it and come back to read more of your useful info.
Thanks for the post. I’ll certainly comeback.
Heya i am for the first time here. I came across this board and
I find It really useful & it helped me out a lot.
I hope to give something back and aid others like you helped me.
If some one wishes to be updated with hottest technologies therefore he must be go to see this website and be up to date daily.
We’re a group of volunteers and opening a new scheme in our community.
Your site offered us with valuable info to work on.
You have done a formidable job and our whole community
will be grateful to you.
Nice post. I used to be checking continuously this blog and I am impressed!
Extremely helpful info specifically the closing phase 🙂 I maintain such information much.
I used to be seeking this certain information for a long time.
Thanks and good luck.
It’s really a nice and helpful piece of info. I’m happy that you just shared this helpful information
with us. Please keep us up to date like this. Thank you for sharing.