Skip to content

Gitea installation & user guide

!!! warning “NOTE, OBS latest chat round” Seems like Gitea expect a git user on the gitea server to handle the SSH door keeping"

Question

    Ok. so a ‘git’ user it is. And, we don’t need to copy the authorized_keys once after the creation of the git user. Just make the change in app.ini

Exactly! You have got it right.

Once you:

  • Create the git user (with the correct shell and home directory).

  • Edit app.ini to set SSH_AUTHORIZED_KEYS_FILE = /home/git/.ssh/authorized_keys. Restart Gitea.

  • Gitea will automatically generate the authorized_keys file in the correct location with all your existing keys (and any future ones you add).

No manual copying is needed. Gitea handles the synchronization automatically. Final Checklist for the Server

Run these commands on your server to finish the setup:**

  1. Create the git user

    sudo useradd -m -s /usr/bin/git-shell git
    sudo passwd -l git
  2. Create the .ssh directory for the git user

    sudo mkdir -p /home/git/.ssh
    sudo chown git:git /home/git/.ssh
    sudo chmod 700 /home/git/.ssh
  3. Edit the config

    sudo nano /etc/gitea/app.ini

**Add this line under [server]:

SSH_AUTHORIZED_KEYS_FILE = /home/git/.ssh/authorized_keys
  1. Restart Gitea to apply changes and regenerate the file

    sudo systemctl restart gitea

    Then test from your laptop:

    ssh -T git@192.168.xxx.xxx

If it says Hi username! You’ve successfully authenticated…, you are done! From now on, adding keys in the web UI will work instantly.

!!! note “END: NOTE, OBS” Move the above down to the correct place if it’s work!!! "

Gitea Installation & Use

Here is the clean, non-Docker installation guide for Gitea on your Linux server.

Step 1: Download and Install the Binary

Download the latest stable release directly to your server.

  1. Create a dedicated user for Gitea (security best practice)

    sudo useradd -r -m -U -d /var/lib/gitea -s /bin/bash gitea
  2. Create necessary directories

    sudo mkdir -p /var/lib/gitea /etc/gitea
    sudo chown -R gitea:gitea /var/lib/gitea /etc/gitea
  3. Download the latest binary (check https://gitea.com/gitea/gitea/releases for latest version) Using a generic wget command for the latest stable Linux AMD64 build

    cd /tmp
    wget https://dl.gitea.com/gitea/1.22.3/gitea-1.22.3-linux-amd64
  4. Make it executable and move to system path

    chmod +x gitea-1.22.3-linux-amd64
    sudo mv gitea-1.22.3-linux-amd64 /usr/local/bin/gitea

Step 2: Initialize the Configuration

Run the binary once to generate the default configuration file and database (SQLite).

Run as the gitea user

sudo -u gitea /usr/local/bin/gitea web --config /etc/gitea/app.ini
  • Wait: It will start a web server on port 3000.

  • Open Browser: Go to http://YOUR_SERVER_IP:3000.

Setup Wizard:

* Database Type: Select SQLite (simplest, no extra DB needed).
* Application Name: e.g., "My Team Git".
* Repository Root: /var/lib/gitea/repos (default is fine).
* Run User: gitea.
* Domain: Your server IP or hostname.
* SSH Port: Choose 22 (if you have no other SSH server) or 2222 (recommended to avoid conflict with system SSH).
* HTTP Port: 3000.
* Create Admin Account: Set a strong username/password for yourself.

* Finish: Click "Install Gitea".

* Stop: Once the setup is done, go back to your terminal and press Ctrl+C to stop the temporary server.

!!! warning “The app data path is invalid: unable to create the APP_DATA_PATH directory: /usr/local/bin/data, Error: mkdir /usr/local/bin/data: permission denied.”

All path in the inital configuration was set to /var/lib/gitea/xx created earlier

pasted-content-2026-04-14T17-24-26

Correct the error

That error happens because when you run sudo -u gitea /usr/local/bin/gitea web, the binary sometimes defaults to looking for data relative to its own location (/usr/local/bin/data) if it can’t find the config file yet or if the GITEA_WORK_DIR environment variable isn’t explicitly passed.

Even though you created /var/lib/gitea, the installer needs to know exactly where to put things before it starts generating the config.

Here is the fix.

You need to explicitly tell Gitea where the work directory is during that initial run.

Run this command instead of the previous one:

sudo -u gitea GITEA_WORK_DIR=/var/lib/gitea /usr/local/bin/gitea web --config /etc/gitea/app.ini

What changed? I added GITEA_WORK_DIR=/var/lib/gitea right before the command. This forces Gitea to use /var/lib/gitea as its base directory for data, logs, and repos, overriding the default behavior that was trying to write to /usr/local/bin/data.

If that still fails(do this first!?)

If the config file /etc/gitea/app.ini doesn’t exist yet, Gitea might be confused. You can force it to create the config in the correct spot by ensuring the directory exists and has permissions:

Ensure permissions are perfect:

sudo chown -R gitea:gitea /var/lib/gitea
sudo chown -R gitea:gitea /etc/gitea

Run the command again

sudo -u gitea GITEA_WORK_DIR=/var/lib/gitea /usr/local/bin/gitea web --config /etc/gitea/app.ini

Once the web interface loads on port 3000, you can proceed with the setup wizard. The wizard will then generate the app.ini file inside /etc/gitea correctly, and subsequent restarts (via systemd) will work fine because the systemd service file I gave you earlier already includes Environment=USER=gitea HOME=/var/lib/gitea GITEA_WORK_DIR=/var/lib/gitea.

!!! warning “Error: code.gitea.io/gitea/modules/git.InitFull failed: failed to get config diff.algorithm, err: exit status 128 - fatal: failed to stat ‘/home/USER/dev’ Permission denied. The ‘/home/USER/dev’ happens to be the directory from where the startup command was launched”

Ah, that explains it perfectly!

The error fatal: failed to stat ‘/home/USER/dev’ Permission denied means Gitea is trying to read the Git configuration from the current user’s home directory (/home/USER/.gitconfig) where you launched the command, but the gitea user doesn’t have permission to read that directory.

Gitea needs to initialize its internal Git environment, and it’s looking at the wrong place because it inherited the “current directory” context from where you ran the command. The Fix

You need to run the command from a directory that the gitea user can access (like /var/lib/gitea or /tmp), or explicitly set the home directory for the command.

Run this command instead:

cd /var/lib/gitea sudo -u gitea GITEA_WORK_DIR=/var/lib/gitea /usr/local/bin/gitea web –config /etc/gitea/app.ini

Why this works:

cd /var/lib/gitea: Changes the current working directory to a place the gitea user owns.
sudo -u gitea ...: Runs the command as the gitea user.
Now, when Gitea tries to access Git config, it looks in /var/lib/gitea/.gitconfig (which it can create) or falls back to its internal defaults, rather than trying to read /home/USER/.gitconfig.

Alternative: Explicitly set HOME

If you prefer to stay in your current directory, you can force the HOME variable for the gitea user:

sudo -u gitea HOME=/var/lib/gitea GITEA_WORK_DIR=/var/lib/gitea /usr/local/bin/gitea web –config /etc/gitea/app.ini

Try the first one (cd /var/lib/gitea…) as it’s the cleanest. The setup wizard should load immediately after this.

Run this command instead:

cd /var/lib/gitea sudo -u gitea GITEA_WORK_DIR=/var/lib/gitea /usr/local/bin/gitea web –config /etc/gitea/app.ini

Why this works:

cd /var/lib/gitea: Changes the current working directory to a place the gitea user owns.
sudo -u gitea ...: Runs the command as the gitea user.
Now, when Gitea tries to access Git config, it looks in /var/lib/gitea/.gitconfig (which it can create) or falls back to its internal defaults, rather than trying to read /home/USER/.gitconfig.

Alternative: Explicitly set HOME

If you prefer to stay in your current directory, you can force the HOME variable for the gitea user:

sudo -u gitea HOME=/var/lib/gitea GITEA_WORK_DIR=/var/lib/gitea /usr/local/bin/gitea web –config /etc/gitea/app.ini

Try the first one (cd /var/lib/gitea…) as it’s the cleanest. The setup wizard should load immediately after this.

!!! warning “OBS, OBS!!”

Yes easiest to cd to /var/lib/gitea, but not allowed as normal user. sudo cd ok???

You cannot use sudo cd because cd is a shell builtin, not an executable program. sudo only works with programs.

However, you don’t need to cd as the gitea user. You can just run the command with the working directory flag or chain the commands.

Here is the single line to run that does exactly what you need (switches directory AND runs the command as gitea):

sudo -u gitea bash -c “cd /var/lib/gitea && GITEA_WORK_DIR=/var/lib/gitea /usr/local/bin/gitea web –config /etc/gitea/app.ini”

What this does:

sudo -u gitea: Switches to the gitea user.
bash -c "...": Runs a new shell command.
cd /var/lib/gitea: Changes directory to where gitea has permission.
&&: Ensures the next command only runs if the cd succeeds.
GITEA_WORK_DIR=...: Sets the environment variable.
/usr/local/bin/gitea web ...: Starts the server.

This avoids the permission error because the command now starts in a directory the gitea user owns. Give that a try! Ok will try. Actually we have added the ’normal’ user to the gitea group, but not yet logged out/in or restarted

That is a great step for convenience, but it won’t fix the immediate error you are seeing right now.

Here is why:

Group membership changes (adding your user to the gitea group) only take effect after you log out and log back in (or restart the session). Until then, your current shell session still thinks you are not in the gitea group.
Even if you were in the group, the error Permission denied happened because the command was running as the gitea user (via sudo -u gitea), trying to read your home directory (/home/USER/dev). The gitea user is not automatically granted access to your personal home folder just because you are in the gitea group.

So, the cd /var/lib/gitea approach is still the correct and fastest fix.

Run this command:

sudo -u gitea bash -c “cd /var/lib/gitea && GITEA_WORK_DIR=/var/lib/gitea /usr/local/bin/gitea web –config /etc/gitea/app.ini”

Once the setup wizard loads and you finish the installation:

Log out and log back in on your local machine to activate the gitea group membership.
Then you can run commands like gitea ... directly without sudo if you want (though for the server service, sudo is still best).

Give that command a shot!

Step 3: Configure Systemd (Auto-start on boot)

Create a service file so Gitea runs automatically.

sudo nano /etc/systemd/system/gitea.service

Paste this content:

[Unit]
Description=Gitea (Git with a cup of tea)
After=syslog.target
After=network.target

[Service]
Type=simple
User=gitea
Group=gitea
WorkingDirectory=/var/lib/gitea
ExecStart=/usr/local/bin/gitea web --config /etc/gitea/app.ini
Restart=always
Environment=USER=gitea HOME=/var/lib/gitea GITEA_WORK_DIR=/var/lib/gitea

[Install]
WantedBy=multi-user.target

Save and exit (if nano: Ctrl+O, Enter, Ctrl+X).

Now enable and start the service:

sudo systemctl daemon-reload
sudo systemctl enable gitea
sudo systemctl start gitea
sudo systemctl status gitea

Step 4: Firewall & Access

Ensure your firewall allows traffic:

If using UFW (Ubuntu/Debian)

sudo ufw allow 3000/tcp   # Web UI
sudo ufw allow 2222/tcp   # SSH (if you chose 2222)

If using firewalld (CentOS/RHEL)

sudo firewall-cmd --permanent --add-port=3000/tcp
sudo firewall-cmd --permanent --add-port=2222/tcp
sudo firewall-cmd --reload

Step 5a: Latest chat

Excellent! 🎉 Getting Gitea up and running is a huge milestone. Now let’s get your Electron project onto it.

Since you already have the project locally (after moving it off the network share), here is the step-by-step to push it to your new Gitea server.

Step 1: Create the Repository on Gitea

  • Log in to your Gitea web UI (http://YOUR_SERVER_IP:3000).

  • Click the + icon (top right) -> New Repository.

  • Name: wave-electron (or whatever you prefer).

  • Visibility: Private (recommended for internal tools).

  • Initialize: Do NOT check “Initialize with README” or “License”. You want a blank repo to push your existing code into.

  • Click Create Repository.

  • You will see a page with instructions. Look for the section “…or push an existing repository from the command line”.

  • Copy the SSH URL shown there. It will look like: ssh://git@YOUR_SERVER_IP:2222/username/wave-electron.git

Step 2: Link Your Local Project to Gitea

Open your terminal in your local project folder (where your package.json is)

  1. Remove any old remote (like the network share or GitHub) git remote remove origin 2>/dev/null || true

  2. Add the new Gitea remote Replace the URL below with the one you copied from Gitea

    git remote add origin ssh://git@YOUR_SERVER_IP:2222/username/wave-electron.git
  3. Push the Code Now, push your code to the server: Push the main branch (or master, depending on your local setup)

    git push -u origin main

If your local default branch is named master instead of main, use git push -u origin master.

  1. Verify on Gitea
  • Refresh the repository page in your browser.

  • You should see your files, commit history, and the package.json.

  • Crucial Check: Ensure node_modules is NOT there. If you see node_modules, you need to add it to .gitignore and remove it from the repo:

    echo "node_modules/" >> .gitignore
    git add .gitignore
    git rm -r --cached node_modules
    git commit -m "Remove node_modules and add to .gitignore"
    git push
  1. Test on the Second Machine

    Now go to your second computer

    • Clone the repo:

      git clone ssh://git@YOUR_SERVER_IP:2222/username/wave-electron.git
    • Enter the folder:

      cd wave-electron
    • Install dependencies (this is the magic step that replaces the network share copy):

      npm install

      Run your app:

      npm start
      # or whatever your start script is

Troubleshooting Tips

SSH Key Error? If git push asks for a password or says “Permission denied (publickey)”, make sure you added your SSH public key to your Gitea profile (User Settings -> SSH Keys).

Wrong Branch? If git push fails saying “main” doesn’t exist, check your local branch name with git branch.

— END — 5a

Step 5: Connect Your Clients

Now you can connect your computers.

Generate SSH Keys (on your local machines if you haven’t):

ssh-keygen -t ed25519 -C "your_email@example.com"
cat ~/.ssh/id_ed25519.pub
  • Add Key to Gitea:

    Log in to http://YOUR_SERVER_IP:3000. Go to Settings (top right) -> SSH Keys. Paste your public key.

  • Clone Your Project: Create a new repository in the Gitea UI (click “New Repository”). Clone it from your local machine:

git clone ssh://git@YOUR_SERVER_IP:2222/username/repo-name.git

(Note the ssh:// prefix and the port 2222).

Next Steps for Your Team

Create the Repo: In the Gitea UI, create a repo named my-electron-project. Migrate Existing Code:

cd /path/to/your/local/project git remote add origin ssh://git@YOUR_SERVER_IP:2222/username/my-electron-project.git git push -u origin main

Set Up Branch Protection (Optional but recommended): Go to Repo Settings -> Branches. Protect main branch: Enable “Require pull request reviews before merging”.

You now have a professional, self-hosted Git server with a web UI, protected branches, and no Docker overhead!