I upgraded my NAS and setup git on it again. I went a little custom this time around, so I’m documenting it here if I ever need to do it again.
The easy stuff:
- Enabled user homes
- Create a
vcs
user - Installed the Git package
- Open Git Server, give
vcs
access to it
Then in a terminal:
sudo mkdir -m 0700 /var/services/homes/vcs/.ssh
sudo sh -c "echo 'ssh key' > /var/services/homes/vcs/.ssh/authorized_keys"
sudo chown -R vcs:users /var/services/homes/vcs/.ssh
sudo chmod 600 /var/services/homes/vcs/.ssh/authorized_keys
Create a test repo:
sudo git init --bare -b master /var/services/homes/vcs/test-repo.git
sudo chown -R vcs:users /var/services/homes/vcs/test-repo.git
Test the clone from your local machine:
git clone vcs@synology.local:test-repo.git
I threw together a quick ‘n dirty script to do all this, create-git-repo
:
From the NAS, I can run ./create-git-repo new-repo-name
, or pass a subpath
with ./create-git-repo itspriddle/awesome-project
.