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 admin@diskstation.local
mkdir /volume1/homes/gituser/.ssh
- copy public rsa key from local computer to gituser account on server
scp ~/.ssh/id_rsa.pub admin@diskstation.local:/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 root@diskstation.local
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 root@diskstation.local
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://gituser@diskstation.local/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/
Thanks for this precious piece of information.
Just a couple of comments, maybe other people may found these helpful:
/var/services/homes-Ootherwise i was getting the errorsubsystem request failed on channel 0Even if your guide does not mention SSHing with gituser, I want to point out that after installing the git service, every user - except root - won't connect anymore on SSH giving the error
fatal: git package does not support interactive shell.To fix this, you will need to edit
/etc/passwdand restore/bin/shas the login shell for all affected users.In addition to this, if you create bare repository directly SSHing with gituser, you won't need to change permissions or ownership of the repo directories.