10 KiB
Gitea
A beautiful self-hosted non-commercial git server. Small but powerful. A better alternative to the monoliths of Github & Gitlab.
- Get set up with these instructions on hosting a gitea server using a raspberry pi
Scripting migrations: If you have a lot of repositories to migrate, it may be easier to write a script to migrate them.
The easiest way to go about this would be to use the Gitea API to create a blank repository, and then use the Git command line to clone repositories from your existing service into Gitea:
git clone --mirror «url to old repository»
git remote set-url origin «url to new gitea repository»
git push --mirror origin
Customizing your Gitea:
- Create a README.md to [your profile](1. https://docs.gitea.com/next/usage/profile-readme)
- create a git profile called
.profile
- then add a single markdown file to the repo
- this will be displayed on your page
- create a git profile called
- To change the front page of the Gitea server, head here for instructions.
- One theme that i like is Cattppuccin! :3 it's really cute. Example
- !
- The entire config cheat sheet is located here.
- The Awesome Gitea Repo for more updates
- For Gitea Pages it is suggested to use Caddy or Codeberg Pages Server
- Adding Themes to Gitea
- Full instructions are found here
More Appearances:
For more information, read here. - User themes - Hotline - HotPink - and more!
- Using Caddy as a proxy
Installing the Gitea Server
There are numerous ways you can install Gitea on your machine but don't get overwhelmed by the choices. Just choose what is easiest for you to get started and you can optimize afterwards.
For me, since I'm currently on a Macbook it will be easiest to do a MacPorts install but perhaps I'll switch it over to be a Linux install at some point later.
- Go to MacPorts, Click your Apple flavor, and download + install the .pkg (no fancy CLI needed for this step!)
- Using Homebrew, install Gitea on your laptop!
- Now go to Linode to set up your server with Alpine Linux.
- Set up steps in this video and create a node
- SSH into the root IP
- Push a test repo and there we have it! You set up your gitea :) !
Gitea Server details
- Site: Shwetha-Base : my self-hosted gitea server
- Path: /var/lib/gitea/data/gitea-repositories
- Run as username: msgit
- Server domain: 172.104.8.87
- Gitea base url: http://172.104.8.87:3000/
- log path:/var/lib/gitea/log
- server port and listening port - 22,3000
Using Gitea Server
Linode
To start the server:
systemctl start gitea.service
Caddy:
Using the gitea server with Caddy: -->add the following server block to your Caddyfile
git.example.com {
reverse_proxy localhost:3000
}
For Caddy with a subpath: In case you already have a site, and you want Gitea to share the domain name, you can setup Caddy to serve Gitea under a sub-path by adding the following to your server block in your Caddyfile:
git.example.com { route /git/* { uri strip_prefix /git reverse_proxy localhost:3000 }}
Then set [server] ROOT_URL = http://git.example.com/git/
in your configuration.
For instructions on syncing your Obsidian vault to your gitea server, head to Obsidian-git sync tutorial.
More references:
- Migrate from github/gitlab to gitea
- Similar to github pages but for gitea
- Gitea for many user databases
- Gitea is highly customizeable. Here is a key of all its configs
- Using gitea with Jenkins
- A self-hosting cloud tutorial
- You can also run gitea on cloudron
- Installing gitea onto raspberry pi
- A gitpod instance of gitea
- gitpod is just an automated dev environment - think of it as a pre-build
- Disaster recovery for Gitea - Gitea’s repository mirroring makes it relatively easy to replicate critical Git repositories so that teams can still work at minimal capacity until the production environment is back up and running.
Issues ...
Further Gitea Commands
Change password within terminal
Change to gitea user:
su git
Update as admin:
gitea --config /etc/gitea/app.ini admin user change-password -u username -p password
via source.
For further questions --> visit the forum discussion.
Further admin commands found here in the docs.
Extras
- Celebrating free software day
- Add SSL certs here by watching this youtube video
Improving Security in Gitea
For additional Gitea updates, always check their blog for release news or security patches.
Spam account story time:
So after about a year of hosting a gitea server..there were a lot of spam accounts that signed on.
Particularly, who the heck is this O/O user?? There seemed to be many mirrors of the same git user which at this point is clearly an automated bot account. Whatever it was scraping I did not want to support the lack-of-context web scraping and dumping onto my git server.
! ! ! Over 3 pages of spam accounts! How the heck?!
So I decide to make sure that the security on my gitea is better. So how do I go about doing this? Google! Go to where you are hosting the server on and continue to log in.
- Logged in as admin and manually purged all the accounts.
- I referred to this Gitea thread on spam account prevention which means future accounts should not be able to sign up without going through a CAPTCHA
[service]
ENABLE_CAPTCHA: false: Enable this to use captcha validation for registration.
CAPTCHA_TYPE: image: [image, recaptcha]
RECAPTCHA_SECRET: ””: Go to https://www.google.com/recaptcha/admin to get a secret for recaptcha.
RECAPTCHA_SITEKEY: ””: Go to https://www.google.com/recaptcha/admin to get a sitekey for recaptcha.
- Implement fail2ban
- Further
service
commands are also listed here. - Change the gitea app.ini file to prevent any users from registering.
2024/08/27 02:06:00 ...eb/routing/logger.go:102:func1() [I] router: completed GET /O/O/commits/commit/7bce1dab984ced815d563901740a5e10>
2024/08/27 02:06:01 ...eb/routing/logger.go:102:func1() [I] router: completed GET /O/O/src/commit/84390c13e11287b2eb9396bdf04662b6d16a>
2024/08/27 02:06:01 ...eb/routing/logger.go:102:func1() [I] router: completed GET /shway/DSA/src/commit/d50e33e1da2e9bf03dedaf82ae333c>
2024/08/27 02:06:01 ...eb/routing/logger.go:102:func1() [I] router: completed GET /shway/DSA/commits/commit/2220849678f7bb46d473733494>
2024/08/27 02:06:01 ...eb/routing/logger.go:102:func1() [I] router: completed GET /shway/DSA/commits/commit/51f788270154d8ac141e8d5e4e>
2024/08/27 02:06:02 ...eb/routing/logger.go:102:func1() [I] router: completed GET /shway/DSA/rss/commit/739e1ba93f6bca9d2df3f28f3377e7>
2024/08/27 02:06:02 ...eb/routing/logger.go:102:func1() [I] router: completed GET /shway/DSA/commits/commit/ac710c7bc43a0d5a0f4269a8a2>
2024/08/27 02:06:03 ...eb/routing/logger.go:102:func1() [I] router: completed GET /shway/Notepad/raw/commit/6181271a30ae50e8fac86d5841>
2024/08/27 02:06:03 ...eb/routing/logger.go:102:func1() [I] router: completed GET /shway/DSA/rss/commit/bd97f4e0b49527e3278b7c3ce7e630>
2024/08/27 02:06:04 ...eb/routing/logger.go:102:func1() [I] router: completed GET /shway/DSA/src/commit/2220849678f7bb46d4737334945fa1>
to update your gitea site settings:
- Go to
/etc/systemd/system/gitea.service
- update the
[Service]
area with all appropriate flags
There was a random user name 'O' that logged into my gitea who mirrored its repo https://dagshub.com/O/O and https://git.froggi.es/O/O . We will need to remove this user.
- Sign in as admin in your gitea
- Go to site settings
- remove the user (oooooooooooooooo@eclipso.email)
To quickly get rid of spam accounts: there is no terminal command as it is not possible to access shell within gitea
- Go to Site Administration
- Click User emails on the left hand side
- On the right hand side of each email, press the check mark under 'Activated' to turn all spam accounts to an 'x' mark for unactivated
- Click into Dashboard on left hand sidebar
- Run the first filter for "Delete all unactivated accounts" !
This will purge all unactivated accounts!