How to setup you repo GIT and local instance (like for GitLab) and not to fall in despair
For a while now, while collaborating with several projects, I noticed that having issues to generated and setup the public keys and configuring the access to GIT repositories was giving a bit of a harsh time to lots of people.
And when in comes to recurring problems there’s nothing better suited than a little reference tutorial to blaze the trail. So, let’s get to it!
#1: generate your SSH key-pair and set it up
Step #1: Check if you don’t already have a key pair
Open a terminal and run the following command:
1
2 3 |
cd ~/.ssh
ls# Lists the files in your .ssh directory |
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 2. Otherwise, you already have an existing keypair, and you can skip to step 3.
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 asked to enter a file in which to save the key, just press enter.
1
2 3 45 |
$ ssh-keygen -t rsa -C "your_email@example.com"
# Creates a new ssh key, using the provided email as a label # Generating public/private rsa key pair. # Enter file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter] ssh-add id_rsa |
Now you need to enter a passphrase.
1
2 |
Enter passphrase (empty for no passphrase): [Type a passphrase]# Enter same passphrase again: [Type passphrase again]
|
Which should give you something like this:
1
2 3 4 |
Your identification has been saved in /Users/you/.ssh/id_rsa.# Your public key has been saved in /Users/you/.ssh/id_rsa.pub.
# The key fingerprint is: # 01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db your_email@example.com |
Step #3: Add your SSH key to GitLab
- Go to your account settings:
- Now go to the SSH keys section:
- Click “Add SSH key”
- Give it a title you like (in the “Title” field) and paste your public key in the bigger “Key” field:
- Click “Add key” and we are done with loading the SSH public key in GitLab!
Step #4: Check everything worked
Now we should have the key pair generated and set up locally and the public key loaded in GitLab. Let’s now make sure this is the case and that everything went fine.
To achieve such a certainty, run the following command:
1
|
$ ssh -T git@git.santexgroup.com
|
If everything went well, you should see an output like this:
1
2 |
$ ssh -T git@git.santexgroup.com
Welcome to GitLab, |
#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 thing 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 at some point went wrong.
Go back and make sure you didn’t miss any steps or ask someone for help.
No hay comentarios:
Publicar un comentario