2 min read
Forgejo + SSH

Some people (https://code.overheid.nl/) are looking for GitHub alternatives as the platform continues to get worse. Some people just wanna try self hosting their repositorys. Forgejo is very good for both of these use cases.

I’ve tried to self host it a bit back but ran into problems with SSH. In hindsight the oversights I made are pretty stupid. But I’m creating this blogpost just in case someone also makes these stupid oversights.

I use Coolify to selfhost my stuff including Forgejo. Coolify has Forgejo listed as a “service” so you can get up and running with it quickly.

The only problem I ran into was using SSH but not because it wasn’t easy to fix. I just didn’t think of the simple things that could be going wrong:

  • SSH port isn’t explicitly configured
  • Firewall isn’t configured properly

In Coolify you should add this line to your compose file:

- 'FORGEJO__server__SSH_PORT=${FORGEJO__server__SSH_PORT}'

and add:

FORGEJO__server__SSH_PORT=222

To your environment variables.

The SSH urls in Forgejo should look something like this now:

SSH clone url

After you’ve done that you should update your Firewall to allow TCP traffic on port 222 in this case.

Now create an account on your Forgejo instance and add your machines public SSH key to your account. Now you should be able to clone repos to your machine using SSH.

By default you can also clone via HTTPS with your login information. This functionality is disabled on GitHub, but not on Forgejo by default.