1. Home
  2. Workspaces
  3. Tools and Features
  4. Virtual Desktops
  5. Setting up GitLab on your Virtual Desktop

Setting up GitLab on your Virtual Desktop

Git is a version control system used for managing and keeping track of code changes over time. To allow collaborative development and sharing of code, you also might want to use a cloud-based hosting service like GitLab that lets you manage Git repositories.

Virtual Desktops host a local GitLab server. It allows multiple users to work in parallel within workspace VMs on the same repo using Git. Because the local GitLab server can only be accessed from workspace VMs, the users are not able to send data out of the local GitLab.

Before you can start using GitLab in your Virtual Desktop, you have to set up an SSH key following the instructions detailed below.

Instructions for Linux

Instructions for Windows

Setting up GitLab on a Linux Virtual Desktop

1. Generate SSH keys

Go into a Linux VM and open a terminal. Take a note of your home folder:

pwd

This command should return something like /home/desktop5.

Next, we generate an SSH key pair:

  • Replace your.email@example.org with the email you used to register to the DRE
  • Replace desktopN with the desktop number retrieved by the previous command
  • Replace id_youruser with a username that would identify your individual key

ssh-keygen -t ed25519 -C "your.email@example.org" -f /home/desktopN/.ssh/id_youruser

It will also ask you to specify a passphrase, you can just hit 'Enter' to skip it.

This will generate a pair of SSH keys as files:

  • /home/desktopN/.ssh/id_youruser – the private key (don’t share!)
  • /home/desktopN/.ssh/id_youruser.pub – the public key (to be shared)

2. Add the key to your GitLab account

Inside the VM, navigate to the GitLab server. You can do this by copying the URL of the current workspace and replacing the workspace name with gitlab. For example, your workspace URL is https://workspace-name.region.environment.your-organisation.org. So, to access the GitLab server, you would use https://gitlab.region.environment.your-organisation.org.

Log in to GitLab with the DRE credentials. Then in the top right corner, select your avatar and click 'Settings'. From the left sidebar, select 'SSH Keys'.

Back in the terminal, copy the contents of your public key:

cat /home/desktopN/.ssh/id_youruser.pub

Then in the GitLab Key box, paste the contents of your public key. If you manually copied the key, make sure you copy the entire key, which starts with ssh-ed25519, and ends with your email address. Then click ‘Add key’.

3. Configure git to use the SSH key

Back in the terminal, configure git with your details and the SSH key:

git config --global user.name "Your name"
git config --global user.email your.email@example.org
git config --global core.sshCommand "ssh -i /home/desktopN/.ssh/id_youruser -F /dev/null"

4. Test the setup

Create a project in GitLab, and then clone it using SSH:

git clone git@gitlab.region.environment.your-organisation.org

Once the project has been cloned, try modifying the code and pushing it to the GitLab repository:

git add --all
git commit -m "Testing GitLab"
git push origin master

You can verify that the repository was updated on the web version of GitLab.

Setting up GitLab on a Windows Virtual Desktop

1. Generate SSH keys

Go into a Windows VM and open the command prompt. Generate an SSH key pair:

  • Replace your.email@example.org with the email you used to register to the DRE
  • Replace id_youruser with a username that would identify your individual key

ssh-keygen -t ed25519 -C "your.email@example.org" -f /c/Users/workspace/.ssh/id_youruser

It will also ask you to specify a passphrase, you can just hit 'Enter' to skip it.

This will generate a pair of SSH keys as files:

  • /c/Users/workspace/.ssh/id_youruser – the private key (don’t share!)
  • /c/Users/workspace/.ssh/id_youruser.pub – the public key (to be shared)

2. Add the key to your GitLab account

Inside the VM, navigate to the GitLab server. You can do this by copying the URL of the current workspace and replacing the workspace name with gitlab. For example, your workspace URL is https://workspace-name.region.environment.your-organisation.org. So, to access the GitLab server, you would use https://gitlab.region.environment.your-organisation.org.

Log in to GitLab with the DRE credentials. Then in the top right corner, select your avatar and click 'Settings'. From the left sidebar, select 'SSH Keys'.

Back in the command prompt, copy the contents of your public key:

cat /c/Users/workspace/.ssh/id_youruser.pub

Then in the GitLab Key box, paste the contents of your public key. If you manually copied the key, make sure you copy the entire key, which starts with ssh-ed25519, and ends with your email address. Then click ‘Add key’.

3. Configure git to use the SSH key

Back in the terminal, configure git with your details and the SSH key:

git config --global user.name "Your name"
git config --global user.email your.email@example.org
git config --global core.sshCommand "ssh -i /c/Users/workspace/.ssh/id_youruser -F /dev/null"

4. Test the setup

Create a project in GitLab, and then clone it using SSH:

git clone git@gitlab.region.environment.your-organisation.org

Once the project has been cloned, try modifying the code and pushing it to the GitLab repository:

git add --all
git commit -m "Testing GitLab"
git push origin master

You can verify that the repository was updated on the web version of GitLab.

Updated on March 10, 2021

Was this article helpful?

Related Articles

Not the solution you were looking for?
Click the link below to submit a support ticket
CONTACT SERVICE DESK