How to Set Up a Secure Self-Hosted Git Server Using Gitea

For developers and teams who want full control over their code repositories, a self-hosted Git server is a great alternative to services like GitHub and GitLab. Gitea is a lightweight, open-source Git hosting solution that offers a fast and simple way to manage repositories. In this guide, we’ll walk you through setting up a secure self-hosted Git server using Gitea.

1. Prerequisites

  • A server (VPS or on-premises) with at least 1 CPU core and 512MB RAM.
  • A domain or static IP address.
  • Basic knowledge of Linux command-line operations.
  • Docker installed on the server (recommended for easy setup).

2. Install Gitea with Docker

Using Docker simplifies deployment and keeps Gitea isolated from other services on your server. Run the following commands to set up Gitea:

mkdir -p /opt/gitea/{data,config}
docker run -d --name gitea \
  -p 3000:3000 -p 2222:22 \
  -v /opt/gitea/data:/data \
  -v /opt/gitea/config:/config \
  --restart=always \
  gitea/gitea:latest

This will download and start the Gitea container, exposing the web interface on port 3000 and SSH access on port 2222.

3. Configure Gitea

Once the container is running, open your browser and navigate to http://your-server-ip:3000. Follow the setup wizard:

  • Choose SQLite, PostgreSQL, or MySQL as your database (PostgreSQL recommended).
  • Set the repository root path.
  • Configure SSH and HTTP settings.
  • Create an administrator account.

4. Secure Your Git Server

To enhance security, consider these measures:

  • Enable HTTPS using a reverse proxy like Nginx with Let’s Encrypt SSL certificates.
  • Restrict SSH access to only trusted users by modifying the SSH daemon settings.
  • Regularly update Gitea to patch security vulnerabilities.

5. Using Gitea

Now that Gitea is up and running, you can create repositories, manage users, and integrate CI/CD tools for automated workflows. Clone a repository using:

git clone ssh://git@your-server-ip:2222/username/repository.git

Conclusion

A self-hosted Git server with Gitea provides flexibility and security while allowing complete control over your code. With proper configuration and security measures, you can ensure a robust development workflow without relying on third-party services.

Illustration of Gitea Git Server Setup:

Comments

Popular Posts

Install Ollama and Open WebUI on Ubuntu 24.04 with NVIDIA GPU Acceleration (Step-by-Step)

Install a Local AI Chatbot on Ubuntu 24.04 with Ollama and Open WebUI (Step-by-Step)

Install Ollama + Open WebUI on Ubuntu 24.04 with NVIDIA GPU Acceleration (Step-by-Step)

Trending Now

Homogeneous Nucleation on Mars: A Textbook Process Finally Observed in Nature

By the end of this piece, you will understand what the Arsia Mons Elongated Cloud is, why it resisted explanation for several years after its first observation, and what the newly published model reveals about a physical process that has never been directly confirmed on any planet's atmosphere. The cloud that broke the model Every morning during Martian spring and summer, a thin, extremely long cloud forms near the Arsia Mons volcano and gradually elongates until it stretches to more than 1,000 miles before dissipating. The cycle then repeats for several months. The formation was first recorded by a probe in 2018, and from that point onward it became a persistent puzzle for atmospheric scientists working with Mars data. The cloud's geometry, its timing, and its seasonal recurrence all pointed to a real and reproducible physical process, yet no existing model could reproduce it. For a technical audience familiar with simulation work, the situation is analogous to a product...