Skip to content

Gitea

Prefer one command? Try the Gitea Playbook

Gitea hosts Git repositories, issues, and pull requests. This guide installs the latest stable binary in ~/opt/gitea, uses MariaDB, and keeps registration closed. The Gitea Playbook automates installation.

Website
Gitea
License
MIT
Author
Uberspace
Last changed
2026-12-05

Tested with Gitea 28.4.0 on Uberspace 8.0.105. We can't guarantee it to work with newer versions.

Report a guide issue

Note

You should be familiar with MariaDB, systemd services, and web backends. Use a fresh Asteroid with port 3000 available. Example output below is abbreviated.

Installation

Resolve the latest stable version from Gitea's download service:

[isabell@moondust ~]$ latest=$(curl -fsS --retry 3 https://dl.gitea.com/gitea/version.json | jq -er '.latest.version')
[isabell@moondust ~]$ echo "$latest"
28.4.0
[isabell@moondust ~]$ mkdir -p ~/opt/gitea
[isabell@moondust ~]$ cd ~/opt/gitea
[isabell@moondust gitea]$ curl -fL --retry 3 -O "https://dl.gitea.com/gitea/${latest:?Resolve the latest release first}/gitea-$latest-linux-amd64"
[...]
[isabell@moondust gitea]$ curl -fL --retry 3 -O "https://dl.gitea.com/gitea/$latest/gitea-$latest-linux-amd64.asc"
[...]

curl -fsS hides progress, shows errors, and fails on HTTP errors. --retry 3 retries temporary failures. jq -er extracts the version as text and fails if it is absent. ${latest:?...} stops the download if the variable is empty. Stop on any error.

Verify the binary against Gitea's published signing key before executing it:

[isabell@moondust gitea]$ mkdir -m 700 .gnupg
[isabell@moondust gitea]$ gpg --homedir .gnupg --keyserver hkps://keys.openpgp.org --recv-keys 7C9E68152594688862D62AF62D9AE806EC1592E2
[...]
[isabell@moondust gitea]$ gpg --homedir .gnupg --verify "gitea-$latest-linux-amd64.asc" "gitea-$latest-linux-amd64"
gpg: Good signature from "Teabot <teabot@gitea.io>" [unknown]
[...]
[isabell@moondust gitea]$ chmod 700 "gitea-$latest-linux-amd64"
[isabell@moondust gitea]$ ln -s "gitea-$latest-linux-amd64" gitea

Configuration

Database and settings

Create a database and private configuration directory:

[isabell@moondust ~]$ mariadb -e "CREATE DATABASE \`${USER}_gitea\` CHARACTER SET utf8mb4 COLLATE utf8mb4_bin"
[isabell@moondust ~]$ mkdir -p -m 700 ~/opt/gitea/custom/conf
[isabell@moondust ~]$ ~/opt/gitea/gitea generate secret SECRET_KEY
[generated secret]

Create ~/opt/gitea/custom/conf/app.ini using a text editor. Replace isabell in paths, domains, and usernames; copy your database password from ~/.my.cnf and use the generated secret. Keep the backticks around the database password:

RUN_USER = isabell
RUN_MODE = prod
WORK_PATH = /home/isabell/opt/gitea

[server]
DOMAIN = isabell.uber.space
ROOT_URL = https://isabell.uber.space/
HTTP_ADDR = 0.0.0.0
HTTP_PORT = 3000
SSH_DOMAIN = isabell.uber.space
SSH_USER = isabell
OFFLINE_MODE = true
LFS_START_SERVER = true

[database]
DB_TYPE = mysql
HOST = 127.0.0.1:3306
NAME = isabell_gitea
USER = isabell
PASSWD = `YOUR_MARIADB_PASSWORD`

[security]
INSTALL_LOCK = true
SECRET_KEY = YOUR_GENERATED_SECRET

[service]
REQUIRE_SIGNIN_VIEW = true
DISABLE_REGISTRATION = true
SHOW_REGISTRATION_BUTTON = false
REGISTER_EMAIL_CONFIRM = true
DEFAULT_ORG_VISIBILITY = private
DEFAULT_KEEP_EMAIL_PRIVATE = true
NO_REPLY_ADDRESS = noreply.isabell.uber.space

[mailer]
ENABLED = true
PROTOCOL = sendmail
FROM = isabell@uber.space

[log]
MODE = console
LEVEL = Info

The mysql driver supports MariaDB. Gitea listens on 0.0.0.0 so Uberspace's proxy can reach it; HTTPS is handled by the web backend. Login is required to view repositories and use the API. Create additional users as an administrator. No Actions runner is installed.

Protect the file, initialize the database, and create your administrator. Use a valid email address you can read:

[isabell@moondust ~]$ chmod 600 ~/opt/gitea/custom/conf/app.ini
[isabell@moondust ~]$ cd ~/opt/gitea
[isabell@moondust gitea]$ ./gitea migrate
[...]
[isabell@moondust gitea]$ ./gitea admin user create --username isabell --email you@example.com --admin --random-password
[...]
New user 'isabell' has been successfully created!

Store the generated password securely or use Forgot password? after starting the service. Do not use reserved usernames such as admin or root.

Service and web access

Create the systemd service and web backend:

[isabell@moondust ~]$ uberspace service add gitea "$HOME/opt/gitea/gitea web" --workdir "$HOME/opt/gitea" --directive Restart=on-failure --directive RestartSec=5 --directive UMask=0077
OK: Created service file: /home/isabell/.config/systemd/user/gitea.service
[...]
[isabell@moondust ~]$ uberspace web backend add "${USER}.uber.space/" port 3000 --force --wait
[...]
OK: Your webserver configuration has been adapted

Open https://isabell.uber.space/ and log in. Create a repository to check the installation.

Limit anonymous crawling

Keep REQUIRE_SIGNIN_VIEW = true in [service] to require login before anonymous crawlers can browse repository pages or use the API. Large crawler fleets can generate substantial load even when individual IP addresses send few requests. Registration is also disabled, so administrators control who receives an account.

If you deliberately need some anonymous access, Gitea also supports REQUIRE_SIGNIN_VIEW = expensive. It blocks selected resource-intensive pages for anonymous visitors, including repository code pages, while leaving other pages accessible. This mode is experimental and may change; the guide and playbook use true by default. See the service configuration reference.

Neither setting prevents requests from reaching the server or replaces protection against request flooding. Restart Gitea after changing app.ini.

SSH setup

Gitea uses your Asteroid's existing SSH service. Use a separate SSH key for Git access and add its public key under Settings > SSH/GPG Keys. Keep the shell-login key registered in the Uberspace dashboard. Do not add the shell-login key to Gitea: a Git key is restricted to Git commands.

On your local computer, select the Git key for this host using ~/.ssh/config:

Host gitea-isabell
    HostName isabell.uber.space
    User isabell
    IdentityFile ~/.ssh/id_ed25519_gitea
    IdentitiesOnly yes

Use the alias in clone URLs, for example git clone gitea-isabell:isabell/example.git. Keep a different SSH alias or explicit key selection for normal shell access.

Debugging

Check service state and the journal:

[isabell@moondust ~]$ systemctl --user is-active gitea
active
[isabell@moondust ~]$ journalctl --user -u gitea -n 50
[...]
... Listen: http://0.0.0.0:3000

For database errors, check app.ini. For email recovery problems, check the user's email address, spam folder, and mailer messages in the journal. Gitea uses local sendmail; no SMTP password is required.

Reset a user's password

Use Forgot password? on the login page. If email recovery is unavailable, run this over SSH. The password prompt keeps the password out of shell history; it is briefly present in the Gitea process arguments:

[isabell@moondust ~]$ cd ~/opt/gitea
[isabell@moondust gitea]$ read -r -s -p 'New password: ' password; echo
New password:
[isabell@moondust gitea]$ ./gitea admin user change-password --username isabell --password "$password"
[...]
[isabell@moondust gitea]$ unset password

Use the Gitea username, which may differ from the Asteroid name.

Updates

Note

Check the release notes and upgrade instructions before updating. Updates are manual.

Backup

Stop Gitea and back up both files and MariaDB. The directory archive includes repositories, LFS objects, configuration, and the current binary:

[isabell@moondust ~]$ umask 077
[isabell@moondust ~]$ backup="$HOME/gitea-backup-$(date +%Y%m%d-%H%M%S)"
[isabell@moondust ~]$ mkdir "$backup"
[isabell@moondust ~]$ systemctl --user stop gitea
[isabell@moondust ~]$ mariadb-dump --single-transaction "${USER}_gitea" > "$backup/database.sql"
[isabell@moondust ~]$ tar -czf "$backup/gitea.tar.gz" -C "$HOME/opt" gitea
[isabell@moondust ~]$ ls "$backup"
database.sql  gitea.tar.gz

Stop if either backup fails. Keep a private copy outside the Asteroid. Restart the service if only taking a backup.

Replace the binary

With Gitea stopped and the backup complete, repeat the version lookup, download, and signature verification from Installation in ~/opt/gitea. Reuse the keyring. Make the verified binary executable and replace the symlink:

[isabell@moondust gitea]$ ln -sfn "gitea-$latest-linux-amd64" gitea
[isabell@moondust gitea]$ systemctl --user start gitea
[isabell@moondust gitea]$ systemctl --user is-active gitea
active

Check the journal, login, repository browsing, and Git push/pull. Database migrations may run at startup. To roll back, stop the service and restore the matching directory and database backup together; an older binary alone cannot undo a database migration. Do not rerun the fresh-install playbook to update.

Further Reading