Create GIT Server in IOCage Jail - In a few easy steps

Sean Hasson

Cadet
Joined
May 27, 2018
Messages
5
Setting up Git Server On FreeNas Jail

Taking some time to share this tried and tested approach *I Took* in order to set-up GIT Server on Jail..
In my implementation I used a zfs mountpoint so that I could have a working code base on a separate disk /pool and also for backup.
Also you will need to setup and enable ssh on your jail - (not covered here)
There are posts for this so not covered here..

SSH KEY NAS

Example Pre-Req:

  • Jail Setup as my Git Server -> e.g 192.168.0.15
  • Create a user on Git Server -> e.g SeanHasson and enable ssh
  • Install Git ->
    Code:
    pkg install git-2.22.0
    *
  • * Note: Particular Version of GIT - do a
    Code:
    pkg search git
    for repo list

Step one in my approach is to setup a SSH key on your server so "as a developer" you dont have to keep inputing your password for checking in etc..

So assuming ssh setup on your GitServer Jail

1.Setup SSH Private Key
On Local Machine
Code:
ssh-keygen
(Leave all options blank and generate key into id_rsa)​
(In my case I Don't generate passcode unless you want to keep being prompted - locally)​

2. Copy Private key to you Git server

Code:
ssh-copy-id SeanHasson@192.168.0.15


  • This will copy your private key to /.ssh/ directory
  • Verify - log on to your Git Server in new tab
  • Verify @ ~/.ssh/ inside should see keys for user
e.g
Code:
cat id_rsa.pub


3. Next Test can log in from Local Machine

Code:
ssh SeanHasson@192.168.0.15​

(Should log in without password)​

4. Create our first Git Repo directory.

So given we are ssh'd on to our Server​
Create a new Repository and init it as a working master (This can be done in different ways - this is the way I did it)​
Code:
mkdir /repos/MyProject.git​
cd /repos/MyProject.git​
git init --bare​


5. Need to setup Git Local If Now Already done///
So if your on Ubuntu or similar
Exit Server or Switch to new Tab (On Local Machine)​
Code:
sudo apt install git​


6.Setup your local config
So set up your user/email locally e.g
Code:
git config user.name Sean Hasson​
git config user.email Sean.Hasson@xxxx.com​


7.Clone a working directory local
Next clone a working directtoy on your local machine by cloning the created repo​
Code:
mkdir MyWorkingDirectory​
cd MyWorkingDirectory​
git clone ssh://SeanHasson@192.168.0.15:/~/repos/MyProject.git​

* It will give a warning about cloning an empty repository...​

8. Commit Something to Start
  • If everything worked you should be able to do something as follows
  • next Add Something to empty Repository and commit
  • The clone should have set remote origin master
Do a
Code:
git branch
to see branch - should be set to master​

Code:
#Navigate to your project repo...​
# Create a file "readme.md"​
cd MyProject​
~/MyWorkingDirectory/MyProject> touch readme.md​
git stage *​
git commit -m "First Commit"​
git push​


9. All DOne

So at this point you should be able to do git pull etc..​
Create a Development Branch and you are off...​
----Tracked Origin​
# git checkout -b "development"​
# ....​
Hopefully helps :)​
 
Top