SSH Key offer the ability to pull and push without the nessecity to type username and password everytime. So it is really a question of winning time and comfort.
First of all go to your peronal settings in the upper right corner:
Then select SSH Key subcategory:
You are now readdy to generate your keys.
The first step will be to generate a SSH Key for the version controlling (What is Git).
I strongly recommend to Windows users to install Git BASH for Windows, so they will have the ability to use the same command as Unix/Linux based command interface. For that simply go to http://gitforwindows.org/ and download the latest release fitting your architecture.
After the installation simply run the Git BASH application, you will have something like that :
For mac users simply open a terminal and type git
For Linux simply get the git package sudo apt-get install git-all
Before generating a new private and public key be sure that don’t already have one using the command :
cat ~/.ssh/id_rsa.pub
If you already have a key it will show something like this, jump below to copy your public key:
If you don’t have any key then write :
ssh-keygen -t rsa -C "your.email@example.com" -b 4096
This command will prompt you for a location and filename to store the key pair and for a password. When prompted for the location and filename, just press enter to use the default. If you use a different name, the key will not be used automatically.
Depending on your platform use the following command to copy your public key :
cat ~/.ssh/id_rsa.pub | clip
pbcopy < ~/.ssh/id_rsa.pub
xclip -sel clip < ~/.ssh/id_rsa.pub
Back to Gitlab, you can now paste (CTRL-V) your key, give it a name like My Awesome PC, and click “Add key” to store it.
Start the ssh-agent in the background:
eval "$(ssh-agent -s)"
Add your SSH private key (the one without .pub
at the end) to the ssh-agent. If you created your key with a different name, or if you are adding an existing key that has a different name, replace id_rsa in the command with the name of your private key file:
ssh-add ~/.ssh/id_rsa
List all the keys, you should see yours in within the ssh-agent:
ssh-add -l
Before doing anything else try your connection to Gitlab with this command:
ssh -T git@gitlab.fabcloud.org
You should recieve a Welcome message like that.
If you get any error at this stage don’t go further! You probably have an error like this Permission denied (publickey).
, so please use the following link to debug https://help.github.com/articles/error-permission-denied-publickey/.
With all these steps you are now able to push without having to pu your username and password, enjoy!