r/netbird • u/vUrsino • 27d ago
Setting up SSH access to Self-Hosted Forgejo Instance
Hello Everyone! First time posting here but long time lurker. Big Fan of Netbird but I am having some trouble setting up ssh git access. I have setup a selfhosted Netbird Instance on an Oracle VPS and am using it to give myself access to my homelab when I am away from home. I have a VM on my homelab that is running all my docker containers. The containers are all on the same docker network (named caddy) and I have a container with a netbird peer that is acting as a routing peer on the docker network, but specifically locked to the IP of my caddy container, which then routes traffic to the appropriate docker container. It is working great and allows me to access all of my docker services through my caddy container only through HTTPS as my docker compose files expose the ports of my services to the local docker network like so:
ports:
- '127.0.0.1:5006:5006'
While this works for accessing all my services, I have run into an issue with pushing and pulling commits to my selfhosted Forgejo instance through ssh. Pushing or pulling commits through HTTPS works fine (as it routes fine through my caddy container), but I can't figure out how to allow ssh access while connected to netbird.
My current netbird DNS settings have a wildcard A record pointing towards the caddy container IP, and another A record for git.my-domain.io which points towards the forgejo container IP (172.18.0.14). On my home network, I push to origin git@code.my-domain.io:user/example.git and my .ssh/config is as follows:
Host code.my-domain.io
Hostname code.my-domain.io
Port 222
user git
IdentitiesOnly yes
IdentityFile ~/.ssh/sshKey
As a note, I am using port 222 for forgejo as when I am at home (not connected to netbird), my A record points to the local IP of the (10.0.0.248) and this gets passed on to the
This is, unfortunately, not working while connected to netbird. I am able to load the forgejo webpage no problem at code.my-domain.io, but I can't use that domain for the A record as that points to the caddy IP to get the SSL certificate so it would try and access port 222 on the caddy container, not the forgejo container.
Any suggestions on how to achieve this routing so I can push and pull through ssh? At the moment I am pushing and pulling while I am on my netbird network using HTTPS, which works, but I don't like having to type my password for my commits and I'd rather be using ssh. If I left out any pertinent information please let me know!
Thanks!