Instructions for setting up a git server on a Synology NAS with Diskstation. Specifically, I am using a DS414 with DSM 5.0.
- Create user gituservia Diskstation interface (with File Station and WebDAV privilages)
- Add new shared folder called git(located at/volume1/git) with read/write access forgituserandadmin. This folder will hold all the repos.
- Install Git Server package via Diskstation
- Open Git Server and allow gituserpermissions
- Enable SSH access on Diskstation (Control Panel > Terminal & SNMP > Enable SSH Service)
- create ~/.sshfolder 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 rootand renameid_rsa.pubtoauthorized_keyson 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
- 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.
- Clone repo from NAS
git clone ssh://[email protected]/volume1/git/<repo-name>.git
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/
I just found another approach which worked for me:
/volume1/git-reposmy-repo,git init --baregit-user(changing the user at the ssh prompt will not work!)git clone ssh://git-user@diskstation:22/volume1/git-repos/my-repoNote: The ssh port may be different on your machine;
diskstationis the DNS name of your diskstation;/volume1/git-repos/my-repois the full path to the created repo sub directory.I guess, for multi user scenarios this will also work if the a special git-users group is created with all git users in it and the created repo directory is assigned to this group with read/write permissions (not tested).
For single user scenarios I observed that if a git repo is created under
/var/services/homes/<user>/git/<repo>it is accessible throughssh://<user>@diskstation:22/var/services/homes/<user>/git/<repo>. Maybe, with the git user group approach from above it will also work in multi user scenarios.DS213j:DSM 6.2.4-25556 Update 8