Connect to GITLAB through a SSH tunnel

This tutorial is  for a scenario  in which we cannot directly access a GITLAB server but can be accessed through another server.

Lan setup for SSH tunnelling
Figure 1 : LAN setup for SSH tunneling

First Create an account in the GITLAB Server.  For that you have to tunnel to the GITLAB server’s HTTP port. Open an terminal an type the following command:

Type the password for the username of the Server. Now,  you should be able to access the GITLAB’s web interface by opening http://localhost:9000 in your browser. In the REGISTER tab fill up the form to create an account.

Login in to your account. To push and pull from the GITLAB server through SSH, we are required to generate a SSH key in our system, then add the SSH public key in your GITLAB’s  account. The following command will let you generate the SSH keys, press the RETURN key to accept the default settings for key generation.

Now, copy the generated public key. To copy your public key to the clipboard, use xclip for Linux Systems:

Navigate to the ‘SSH Keys’ tab in you ‘Settings’, and paste the key in the Key Field. Add a title as the name of your PC (any  name to identify your PC).

Screenshot for SSH keys tab (Click to enlarge)

Create a repository in your GitLab account. After creation of the repository you can clone to your computer through SSH. For that you need to  create an ssh tunnel in port 22(SSH)

Now you can add your sources codes in the cloned repository. To test, add an file inside the repository, commit and push to the Gitlab Server.


Machine Learning Enthusiast | Traveler | Pet Lover