Andrew Hofmans

  • Foundation smoke home
  • How-To
  • projects
  • reference

Access Git repo over SSH behind jumpbox

Published: Mon 13 January 2020
By Andrew Hofmans

In How-To.

tags: bash git server ssh

I recently ran accross the situation where I wanted to push changes to a repo that was stored on my personal Gitlab server. The issue was that I had recently restructured my homelab and the only way to get to the gitlab server via SSH was through a jumpbox. These were the steps I took to be able to use the normal git workflow while still keeping my network design / security choices intact.

On dev machine

First we will create a new SSH key for the hop from dev machine --> jumpbox.

ssh-keygen -t ed25519 -C "gitlab multihop" -f ~/.ssh/multihop.ed25519 -N ""

This creates a new SSH key (ed25519 type) called multihop.ed25519 with no passphrase and stored in our profile's .ssh directory.

Copy it to the jumpbox

ssh-copy-id -i ~/.ssh/multihop.ed25519 username@jumpbox

Now edit (or create) your profile's SSH config file and add in the host parameters.

vi ~/.ssh/config

Host jumpbox
  User jumpboxusernamehere
  Port 22
  IdentityFile ~/.ssh/multihop.ed25519



Host gitlab
  Hostname gitlab.ip.or.hostname
  Port 22
  ProxyJump jumpbox.ip.or.hostname
  User gitlabboxusername
  IdentityFile ~/.ssh/multihop_ed25519

Now you can use the standard git commands and connect to your gitlab instance through an SSH jumphost.

Proudly powered by Pelican, which takes great advantage of Python.

The theme is by Smashing Magazine, thanks!