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
gituser
via Diskstation interface (with File Station and WebDAV privilages) - Add new shared folder called
git
(located at/volume1/git
) with read/write access forgituser
andadmin
. 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)
- 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 renameid_rsa.pub
toauthorized_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
- 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/
Thank you for your post.
I do stumble with "Open Git Server and allow
gituser
permissions".I do not find anything to edit anything with the installed Git server.
As I understand it from your explanation, there is a
Git-Server/Settings/Users
navigation path to manage/add users.Note: I just found it. I always looked at the installed packages in the Package Center. But it is located at the "Main Menu". The place where all installed applications have their starting home.
Another issue I watched (if I got it right):
It is metioned that
git update-server-info
is somewhat needed; probably also or instead it is needed to set the chown again. I had the 'feeling' that the git server places new files into his .git folder with root:root ownershipwhich breaks the git commands executed as/from client.