Exclusive Metin2 game shield on FreeBSD: Automatic siege mode, VIP list, and whitelist from your dashboard. See how it works
Create a server

Guide

How to Set Up a Git Server on a VPS

A bare repository on your VPS works as a private SSH remote without GitHub.

Steps

  1. Install Git and create the service user:

    sudo apt update
    sudo apt install -y git
    sudo adduser --system --shell /bin/bash --group --disabled-password --home /home/git git
  2. Authorize your public key for the git user:

    sudo mkdir -p /home/git/.ssh
    sudo tee -a /home/git/.ssh/authorized_keys < ~/.ssh/id_ed25519.pub
    sudo chown -R git:git /home/git/.ssh && sudo chmod 700 /home/git/.ssh && sudo chmod 600 /home/git/.ssh/authorized_keys
  3. Create a bare repo:

    sudo -u git mkdir -p /home/git/repos
    sudo -u git git init --bare /home/git/repos/project.git
  4. From your PC, add the remote and push:

    git remote add origin git@YOUR_IP:/home/git/repos/project.git
    git push -u origin main

Tips

  • Disable SSH password login and use keys only.
  • For multiple projects, one bare repo per folder under /home/git/repos.

ext step

Infrastructure for your private remote: Deploy your Cloud VPS.

Related guides