Part 1: create a new user (git) and set up SSH to prepare remote server for a cgit instance
Note: I took these notes a few months ago, when I started to set up my own cgit instance. There might be some omissions, or mistakes. Feel free to email me if you have questions.
Create a user git
I read that it’s best to create a dedicated user, so that if many contributors need to access the remote repository on the VPS, the maintainer/admin only needs to provide others with the SSH access to the user git (or whatever you want to call it).
To create a user run:
adduser git
Choose a password for the user git. You should not need this password in the future if your local machine will authenticate to the server via SSH.
Switch from root to user git:
# su git
Set up SSH
Make sure you are in the home i.e. ~ directory:
/$ cd
~$
Notice the ~.
Create a .ssh directory:
~$ mkdir .ssh
Make sure .ssh is only accessible by the user git:
~$ chmod 700 .ssh
Create a file that will hold the SSH public keys of users who are authorized to access the remote repository we are creating:
~$ touch .ssh/authorized_keys
Make this file only accessible by user git:
~$ chmod 600 .ssh/authorized_keys
So far we’ve been on the VPS only; now we go onto the local machine.
Copy your own SSH public key to the server
We will copy the SSH public key of the (local) user onto the VPS, so the user can interact with the remote repository:
$ ssh root@93.95.229.191 'cat > /home/git/.ssh/authorized_keys' < .ssh/id_key
What does this command do?
- we SSH into the VPS via root
- we feed the file
/home/git/.ssh/authorized_keyswith the key of the file.ssh/id_key.
You can check that the SSH public key of local user was copied to /home/git/.ssh/authorized_keys:
~$ cat .ssh/authorized_keys
ssh-rsa BBBBeB....k8d53kf0ikDD
Next post: install and setup cgit config for the instance: https://yctct.com/cgit-instance-setup-2
personal computing command-line interface (cli) gnu linux trisquel shell literacy wiki cgit git hosting