Posted on

Setup Secure SSH Connection

Generate SSH key using the remote workstation then secure copy to RaspberryPi

ssh-keygen -t rsa -b 4096 -C "remoteuser"

enter file path and name to save or press enter to use default (/home/pi/.ssh/id_rsa): pi
This should create 2 filesthat will contain private and public keys.

cd .ssh
scp pi@[RaspberryPi]:/home/pi/ 

check version of Git & Install gitolite

git --version 
sudo apt-get install git-core gitolite3

Add the SSH key generated to gitolite

Add user ssh keys to the lists

gitolite3 setup -pk  /home/pi/ 

The file should be added to the list /var/lib/gitolite/.ssh/authorized_keys

To add New User to Raspberry Pi

Add new user(s) fill in password, full name, room number, work phone, home phone, other and confirm it is correct. Then add group

sudo adduser [remoteuser] 
sudo addgroup developers

add [remoteuser] user to the developers group.
Validate using: groups [remoteuser]

sudo usermod -a -G developers [remoteuser] 

Create a root directory for repositories and add to developers group. in this example a directory named git will be created in directory /home/pi

mkdir -p /home/pi/git 
sudo chgrp developers /home/pi/git/*
sudo chmod g+rws /home/pi/git/*
ls -l
#total 4
#drwxrsxr-x 8 pi developers 4096 May 25 00:22 git

Start working with repositories

Add a blank repository by creating a directory then initialize git

mkdir -p /home/pi/git/myFirstRepository
cd  /home/pi/git/myFirstRepository 
git init --bare --share

Now at remote workstation with git installed, navigate to git work folder with remote repository connect it to gitolite server .

git remote add remoteRepository pi@