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/

The "NO interactive users" comes from the file
~gituser/git-shell-commands/no-interactive-loginThis file is sourced by git-shell which is the assigned shell for gituser once it is associated with GIT.
You can remove this file
rm ~gituser/git-shell-commands/no-interactive-loginOR rename it
mv ~gituser/git-shell-commands/no-interactive-login ~gituser/git-shell-commands/no-interactive-login.HOLDRemember to move it back or recreate once you are done.
I would login and check if you can initialise a repository using the commands
You need root or admin access.
Sudo to gituser
sudo -u gituser bashChange directory to git directory
cd /volume1/gitCreate an empty git repository In this example I am calling it TestRepository. This would be the name it accessed as remotely
git --bare init TestRepository.gitFinally remember when adding the repository into windows, linux or OS X git tools you must use the full name TestRepository.git.
Trouble shooting the requirement for password
First check what it is doing using the ssh client in verbose mode.
ssh -vvv gituser@192.168.2.100You are looking for information on matching keys etc.
Be aware that it could be rejected because
.ssh/authorized_keysdoes not exist or permissions are incorrect on the file or the.sshdirectory on the Synology. You also need to be aware of name or IP address mismatches between files. If your id_rsa.pub file has an old hostname or IP address in it then this will not match.The ssh client will require a password if you have created a password on your private key file on your local machine. It is difficult to remove this and not break other things, so i would recommend you creating another one.
ssh-keygen -t rsa -f gituser_rsaGenerating an ssh key on a mac os x
You will then need to append the
gituser_rsa.pubfile onto the.ssh/authorized_keysfile.Hope these things help.