Gitea
To setup a private Git service via SSH protocol in LAN,
create a new user git
on the host.
This os_user_name
is used in installation process, and appear in the repo address:
<os_user_name>@192.168.0.254:<gitea_user_name>/<repo_name>.git
.
Following the conventions of repo address format of Github or Gitlab,
we name it git
:
sudo useradd -m -s /bin/bash -g dataprovider -p $(openssl passwd -1 mygitpwd191224) git
Then copy gitea
executable to /opt/git_service and change the owership:
sudo chown -R git:dataprovider /opt/git_service
Login as git
and start the service:
su - git
cd /opt/git_service
./gitea web
Open 192.168.0.254:3000 in browser, modify the following install parameters:
Database Type: SQLite3
Domain: 192.168.0.254
Application URL: http://192.168.0.254:3000/
Do NOT forget create admin account in the bottom of this installation page.
After login, add client host's SSH key. Create a new repo, and push to the service from the client.
To reinstall Gitea from scratch, delete everything in folder /opt/git_service
execpt gitea
itself and run gitea web
again.
To disable password complexity check when register,
add PASSWORD_COMPLEXITY = off
under the [security]
section in file $GITEA_HOME/custom/conf/app.ini.
See Configuration Cheat Sheet for details.
You can't delete an issue, but you can modify its title and contents. You could delete the record of the issue in database (however not recommended):
$ sudo apt install sqlite3
$ su - git
$ cd /opt/git_service/data
$ sqlite3 gitea.db
sqlite> .tables
sqlite> SELECT * from issue
Gogs
Today I followed the instructions on Install from binary, download the gogs binary for Linux amd64 with tar.gz extension to a vagrant virtual host on ThinkCenter (IP address 172.18.0.244). Extract it to ~/apps/gogs folder:
sudo useradd -m -p $(openssl passwd -1 mygitpwd) git
su - git
mkdir apps; cd apps
tar xf /vagrant/gogs0.11.34.tar.gz
cd gogs
./gogs web # or use another port with '-port 3001'
Open 172.18.0.244:3000 in browser, modify the following install parameters:
Database Type: SQLite3
Domain: 172.18.0.244
Application URL: http://172.18.0.244:3000/
Then click Install Gogs to install Gogs service. After that click Sign up now to register a new user leo. This user will be the administrator of the gogs system.
Run as Daemon
According to How do I run Gogs at startup with Systemd?.
Modify the following items in $GOGS_HOME/scripts/systemd/gogs.service
:
WorkingDirectory=/home/git/apps/gogs
ExecStart=/home/git/apps/gogs/gogs web
And comment out After=mariadb.service mysqld.service ...
,
for here we use SQLite3 instead of mariadb, etc.
Copy the file into folder /etc/systemd/system
and run:
sudo systemctl enable gogs
sudo systemctl start gogs
There's also an init.d script provided, which is more complicated to configure than the systemd equivalent.
Note:
Don't use existing user as the gogs Run User. Thus the normal SSH connection will be interfered by Gogs.
Backup and Restore
Backup: ./gogs backup
and save the created file in the current folder:
gogs-backup-xxx.zip.
Restore: ./gogs restore --from="gogs-backup-xxx.zip"
.
Notice that the user name of the backup and restore must be the same, or the restore will failed.
Follow How to backup, restore and migrate for details.
Clone with SSH
After adding the client's SSH public key in Gogs Your Settings > SSH Keys, I could push an existing repository to Gogs:
git remote add gogs git@172.18.0.244:leo/programming-style.git
git push gogs master
And clone it from Gogs:
git clone git@172.18.0.244:leo/programming-style.git
.
Under the hood, Gogs add something like the following lines to file ~/.ssh/authorized_keys of user git:
command="/home/git/apps/gogs/gogs serv key-1 --config='/home/git/apps/gogs/custo
m/conf/app.ini'",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty
ssh-rsa <your-pub-key>
So if you can't push via ssh, check if the contents in authorized_keys is generated correctly.