Skip to content

Instantly share code, notes, and snippets.

@walkerjeffd
Last active July 4, 2025 16:31
Show Gist options
  • Save walkerjeffd/374750c366605cd5123d to your computer and use it in GitHub Desktop.
Save walkerjeffd/374750c366605cd5123d to your computer and use it in GitHub Desktop.
Instructions for setting up git server on Synology Diskstation

Configure Synology NAS as Git Server

Instructions for setting up a git server on a Synology NAS with Diskstation. Specifically, I am using a DS414 with DSM 5.0.

Set Up User and Folder

  • Create user gituser via Diskstation interface (with File Station and WebDAV privilages)
  • Add new shared folder called git (located at /volume1/git) with read/write access for gituser and admin. This folder will hold all the repos.
  • Install Git Server package via Diskstation
  • Open Git Server and allow gituser permissions
  • Enable SSH access on Diskstation (Control Panel > Terminal & SNMP > Enable SSH Service)

Configure SSH Access

  • create ~/.ssh folder for gituser on server
ssh [email protected]
mkdir /volume1/homes/gituser/.ssh
  • copy public rsa key from local computer to gituser account on server
scp ~/.ssh/id_rsa.pub [email protected]:/volume1/homes/gituser/.ssh
  • connect via SSH as root and rename id_rsa.pub to authorized_keys on NAS (or append if already exists, cat id_rsa.pub >> authorized_keys)
ssh [email protected]
mv /volume1/homes/gituser/.ssh/id_rsa.pub /volume1/homes/gituser/.ssh/authorized_keys
  • change permissions while logged in as root
cd /volume1/homes/gituser/
chown -R gituser:users .ssh
chmod 700 .ssh
chmod 644 .ssh/authorized_keys

Set Up New Repo on NAS

  • create bare repo as root
ssh [email protected]
cd /volume1/git/
git --bare init <repo-name>.git
chown -R gituser:users <repo-name>.git
cd <repo-name>.git
git update-server-info

NOTE: I'm not entirely sure if git update-server-info must be run for each repo or just initially. It seems to work without running this command, but I'm suspcicious that it might cause problems later.

Add NAS as Remote for Local Repo

  • Clone repo from NAS
git clone ssh://[email protected]/volume1/git/<repo-name>.git

References

http://blog.osdev.org/git/2014/02/13/using-git-on-a-synology-nas.html http://stackoverflow.com/questions/20074692/set-up-git-on-a-nas-with-synologys-official-package http://www.heidilux.com/2014/02/setup-git-server-synology-nas/

@CameronD73
Copy link

CameronD73 commented Jun 30, 2025

Hi there! As far as I understood this thread, there is no way to use Synilogy Git server when your NAS not in local network. Is there any way to use QuickConnect Id or something else?

I don't think there is anything in this thread that means it only ever works on local networks - but that would be how most people use it.

I don't know anything about quick-connnect, except that I don't use it.

I don't think there is anything totally blocking access via port forwarding, but you would need to be really careful exposing it to the internet, especially port 22 which will get flooded with brute force attacks.
The only way I would do it would be to create a vpn between the two sites - that way the client appears to be local. It does require at least one side to have static, or at least stable IP address.
There are possibly firewall rules that you might have to relax.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment