Git 'forge' with bare ssh

2026-05-14

I was figuring out how to use cgit when I discovered that I can just “host” it with plain ssh.

Uploading your repo to your server

Assuming you already have your ssh access to the server, make a bare 1 repository and upload it somewhere.

git clone --bare proj proj.git
sftp user@ip:folder

note the scp notation :folder here, if we want to add it as a remote, we have to use user@ip:<path_to_.git_folder>. 2

Add remote and push there

git remote add origin user@ip:folder

The above use the scp notation2…. and it’s done.

Honestly didn’t expect it to be this simple, but here we go, a fully functioning git remote without any web stuff or config.

Use git user

After a while, it can be cumbersome to type some dir address into the clone, and using a normal user for that is not really a good idea for security.

It’s better to have a dedlicated and restricted git user that is used to manage the repos.

See https://git-scm.com/book/en/v2/Git-on-the-Server-Setting-Up-the-Server, the process is the same for FreeBSD.

  1. https://git-scm.com/book/en/v2/Git-on-the-Server-Getting-Git-on-a-Server

  2. https://git-scm.com/book/en/v2/Git-on-the-Server-The-Protocols ↩2


(This is the latest article.)Funny C Programs I've Collected >