I wanted to use my drobo as a git server that I could push my repositories to mostly for back up reasons, but also to enable light collaboration with users also on my LAN. This wasn’t so straight forward, but I got it working and decided to document it here in case others are interested. I got this to work on my Drobo 5N2. This may work on other NAS models, but I cannot personally verify that.
Step 1 - Install the software
Install the DropBear and Git SCM Drobo apps onto the Drobo using the Drobo dashboard.
Step 2 - Create git User on Drobo
Log onto the Drobo via ssh using your admin credentials. For example: ssh firstname.lastname@example.org
Once logged in, you need to create a git user and then set the user up so that you can use password less login:
sudo adduser -h /mnt/DroboFS/home/git git
sudo su git
mkdir .ssh && chmod 700 .ssh
touch .ssh/authorized_keys && chmod 600 .ssh/authorized_keys
Now open the .ssh/authorized_keys file for editing, and insert the public ssh key from your client computer (where you git repositories are). The public key is usually in ~/.ssh/id_rsa.pub on unix-like systems. Save the .ssh/authorized_keys and log out of the drobo as both git and admin.
Step 3 - Create Repository on Drobo
Log onto the Drobo as git user: ssh email@example.com. If you did Step 2 correctly, you shouldn’t need to enter a password. Now you need to make a repository folder on one of your shares. You can find the shares at:
cd into one of the shares and make a directory with its name ending in .git. For example, my-repository.git. Once made, cd into it and init a bare git repository:
git init --bare
Log out of the Drobo.
Step 4 - Connect Local Repository to Drobo Server
Now this is the not-so-straightforward step. The reason is the Drobo doesn’t set up the PATH environment variable for the install apps (i.e., git) such that the git software can be found for non-interactive shell session, which is what git uses to communicate with the server. So we need to tell git on the client computer where the git software can be found on the server (the Drobo).
cd into your repository directory on your client computer, and set up a remote:
git remote add archive firstname.lastname@example.org:/mnt/DroboFS/Shares/path/to/my-repository.git
Of course, change path/to/my-repository.git to the path to the git repository folder you created on the Drobo in Step 3. Also, drobo.ip.address need to be replaced with the IP address of your Drobo on your local network. Finally, I called the remote archive in this example. Another popular name is origin. Change the remote name as you see fit.
Now we need to tell git on the client computer where it can find the needed software on the Drobo:
git config remote.archive.uploadpack /mnt/DroboFS/Shares/DroboApps/git/bin/git-upload-pack
git config remote.archive.receivepack /mnt/DroboFS/Shares/DroboApps/git/bin/git-receive-pack
Change the string archive in each command to the name of the remote if you used a different name. Finally, you can push your local repository to your Drobo server
git push archive master
That’s it! Repeat Steps 3 & 4 for every new repository you want to add to your Drobo git server. Repeat the last part of step 2 (copying the public SSH keys) for every new contributor you want to add to your git repositories.
Cloning a Repository from the Drobo Git Server
When you later want to clone the repository from the git server on the Drobo, you have to tell your client git software where the server-side software is because, again, the PATH information on the Drobo host isn’t set up. The command to do this is as follows:
git clone -u /mnt/DroboFS/Shares/DroboApps/git/bin/git-upload-pack -o archive -c remote.archive.uploadpack=/mnt/DroboFS/Shares/DroboApps/git/bin/git-upload-pack -c remote.archive.receivepack=/mnt/DroboFS/Shares/DroboApps/git/bin/git-receive-pack git@drobo-5n2:/mnt/DroboFS/Shares/path/to/my-repository.git
To unpack this command a little, the options used are:
- -u - this option tells the clone command where it can find the git upload pack on the git server (the Drobo).
- -o - sets the name of the remote (the git repository on the Drobo) in the local clone of the repository. You can set this to what ever you want. If you don’t use this option, the remote’s name defaults to remote.
- -c - this sets configuration variables in the cloned repository. There are two instances of this option as we need to set the location of the server side git upload and download pack, much as we did in step 4 above. As in step 4 above, change the string archive in each command to the name of the remote if you used a different name in the -o option.
As before, change path/to/my-repository.git to the path to the git repository folder you created on the Drobo in Step 3 of the repository creating process above.