Exercise: Hosting Git Repositories on a Linux Virtual Machine
Overview
In this exercise, you will set up a Linux virtual machine (VM) that acts as a server for hosting Git repositories. You will do this in two stages:
-
Stage 1 - Pure Git over SSH The VM will host Git repositories that are accessed directly via SSH. Authentication must be done using SSH keys, so that no usernames or passwords are required when cloning, pulling, or pushing.
-
Stage 2 - Git Hosting Platform The VM will run a Git hosting platform such as Gitea or GitLab, which provides a web interface for managing repositories, users, and permissions.
In both stages, you must always verify your setup by creating and working with at least two different repositories from the host machine (your laptop) on which the VM is running.
You will also create a protocol document where you track your progress, record what you tested, and document the results.
No step-by-step instructions are given. You must research and decide how to reach each goal on your own.
Stage 1 — Git Repositories via SSH
Goal
Your Linux VM must be able to:
- Act as a Git server.
- Accept SSH connections from your host machine.
- Authenticate using SSH keys only.
- Allow cloning, pushing, and pulling without asking for credentials.
- Host at least two separate Git repositories that can be accessed independently.
From your laptop, you should be able to:
- Clone repositories from the VM via SSH.
- Make commits locally.
- Push commits back to the VM.
- Pull changes from the VM.
Required Tests
To verify that your setup works, your protocol must show evidence that you have successfully:
- Generated at least one SSH key pair on the host machine.
- Installed the public SSH key on the VM for Git access.
- Connected to the VM using SSH without entering a password.
- Created Repository A on the VM.
- Created Repository B on the VM.
- Cloned Repository A from the VM to the host machine.
- Cloned Repository B from the VM to the host machine.
- Made a commit in Repository A and pushed it to the VM.
- Made a commit in Repository B and pushed it to the VM.
- Pulled changes from both repositories to confirm access works in both directions.
Stage 2 — Git Hosting Platform (Gitea or GitLab)
Goal
Your Linux VM must now:
- Run a Git hosting platform (for example: Gitea or GitLab). I recommend Gitea, because it uses far fewer resources (memory/CPU) than GitLab.
- Provide a web interface for managing repositories.
- Allow you to manage repositories using the platform instead of manually on the filesystem.
- Provide secure (encrypted) access to repositories via SSH or HTTPS.
From your laptop, you should be able to:
- Access the web interface of the platform.
- Create and manage repositories via the web UI.
- Clone, push, and pull repositories.
Required Tests
Your protocol must show evidence that you have successfully:
- Installed and started a Git hosting platform on the VM.
- Accessed the platform’s web interface from the host machine.
- Created a user account (if required by the platform).
- Created Repository C using the platform.
- Created Repository D using the platform.
- Cloned Repository C to your host machine over a secure connection.
- Cloned Repository D to your host machine over a secure connection.
- Made commits in both repositories and pushed them successfully.
- Verified in the web interface that the commits appear correctly.
Protocol (Documentation Requirement)
You must create a protocol document (logbook) in which you track your work.
Your protocol must contain:
- Date and time for each work session.
- A short description of what you attempted.
- The result of each test.
- Problems you encountered.
- How you solved those problems.
- Screenshots or command outputs as evidence where appropriate.
Completion Criteria
You have successfully completed the exercise if:
- Stage 1 works fully with two repositories over SSH using keys only.
- Stage 2 works fully with two repositories managed by a Git hosting platform.
- All required tests are documented in your protocol.
- Your protocol is clear, complete, and understandable for someone who was not present during your work.