logo
podcast Podcast
get help Get Unstuck

Connecting to a git repo through an SSH tunnel

SSH config is your friend

Joel Clermont
Joel Clermont
2024-10-31

When you work with as many different clients as we do, you realize that not everyone hosts their repos on GitHub or some other service. Some clients have their own internal servers, which are not publicly accessible.

So how do we connect to those?

In most cases, the client can whitelist a specific IP for us to connect from, and we have a proxy server with a static IP that we use to funnel traffic through.

Great! But how do you set it up so that git clone will know to use the proxy server?

Enter the SSH config file:

# ~/.ssh/config

Host internal-git-server.client.com
    ProxyJump our-proxy.server.com

Now, whenever I interact with this repo using git (or even a GUI client, like in PHPStorm), it automatically uses my proxy configuration. It's totally transparent to me after I set it up this one time.

And there are lots of other handy things you can do with the SSH config file too.

But what if this server doesn't support SSH and you can only connect with HTTPS? Stay tuned for tomorrow's tip.

Here to help,

Joel

P.S. Reading the docs can be boring, but I promise that reading our books won't be.

Toss a coin in the jar if you found this helpful.
Want a tip like this in your inbox every weekday? Sign up below 👇🏼
email
No spam. Only real-world advice you can use.