screen-shot-2013-02-25-at-12.57.36-pm_130x100

Setting up git on Synology NAS

I just finished setting up my brand new Synology Rackstation 812 NAS.  I quickly installed subversion and next up, git:

1. Configure ssh in the DSM if you haven’t already done so.  Log into the web interface (DSM) and select Control Panel –> “Terminal”  and check the “Enable SSH service check box.  Click the Apply button.

Screen Shot 2013-04-03 at 9.03.00 PM

2. Create a user account for yourself.  Create a file share in DSM and give both admin and your user read/write access.  Mine is aptly named “git”  This will create a /volume1/git directory.

3. Log into the Synology NAS via ssh as root.  The root password will be your admin password that you set when you first installed DSM.

4. If you haven’t already done so, figure out what the CPU is in your NAS and install ipkg.  Follow the steps HERE.  Once you have installed ipkg, use ipkg to install git:

syn > ipkg install git

 

If you get an error saying git not found, update ipkg and try again.  This will install git.  To test to make sure git is working:

syn > su user1  #<-- your user name that you created.
syn > cd /volume1/git
syn > mkdir test
syn > cd test
syn > git init . --bare

 

4. Make sure you enabled the user home service, which should create your /home/<user> directory.  This is in Control Panel –> Users –> Home.

Screen Shot 2013-04-03 at 9.26.40 PM

5. Next, we have to configure sshd so that git+ssh works.  Trying to clone our repository we just created will fail:

git clone ssh://192.168.0.29/volume1/git/test
Initialized empty Git repository in test/.git/
sh: git-upload-pack: not found
fatal: The remote end hung up unexpectedly

This means that git logged into the NAS via ssh, but couldn’t find the “git-upload-pack” command in the PATH, because the path omits the /opt/bin directory where ipkg puts downloaded executable files.  There are several ways to fix this.  Since sshd for BusyBox was configured not to parse the /etc/profile or ~/.profile of the user, we can try to set the path in a ssh environment file, or we can simply create symbolic links.

As root:

cd /usr/bin
ln -s /opt/bin/git* .

 

You should now be able to clone a git repository and check files in.

Leave a Reply