85 lines
2.5 KiB
Markdown
85 lines
2.5 KiB
Markdown
# New Server Onboarding — Connect to Gitea
|
|
|
|
Give this prompt to an AI on any new server that needs to connect to this
|
|
Gitea instance and create/push a repository.
|
|
|
|
---
|
|
|
|
## Prompt
|
|
|
|
```
|
|
I need to initialise a git repository on this server and connect it to a
|
|
self-hosted Gitea instance on my LAN. Please help me with the full setup.
|
|
|
|
GITEA SERVER DETAILS
|
|
--------------------
|
|
Public URL: https://g.pozi.co.za
|
|
LAN URL: http://192.168.0.126:3000
|
|
Admin user: gadmin
|
|
API token: (request from owner)
|
|
|
|
SSH ACCESS (use LAN since we are on the same network)
|
|
------------------------------------------------------
|
|
Host: 192.168.0.126
|
|
Port: 22
|
|
User: git
|
|
Clone format: git@192.168.0.126:gadmin/REPONAME.git
|
|
|
|
WHAT I NEED YOU TO DO
|
|
----------------------
|
|
1. Check if git is installed:
|
|
git --version
|
|
If not, install it (Debian/Ubuntu):
|
|
apt-get install -y git
|
|
|
|
2. Identify this server:
|
|
hostname && cat /etc/os-release | head -5
|
|
|
|
3. Generate an SSH key for this server:
|
|
ssh-keygen -t ed25519 -C "$(hostname)@gitea" -f ~/.ssh/id_gitea -N ""
|
|
cat ~/.ssh/id_gitea.pub
|
|
|
|
4. Register this server's SSH key with Gitea:
|
|
curl -X POST http://192.168.0.126:3000/api/v1/user/keys \
|
|
-H "Authorization: token API_TOKEN_HERE" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"key\":\"$(cat ~/.ssh/id_gitea.pub)\",\"read_only\":false,\"title\":\"$(hostname)-server\"}"
|
|
|
|
5. Add ~/.ssh/config entry:
|
|
mkdir -p ~/.ssh && cat >> ~/.ssh/config << 'EOF'
|
|
|
|
Host gitea-lan
|
|
HostName 192.168.0.126
|
|
User git
|
|
Port 22
|
|
IdentityFile ~/.ssh/id_gitea
|
|
EOF
|
|
chmod 600 ~/.ssh/config
|
|
|
|
6. Test the connection:
|
|
ssh -T git@192.168.0.126
|
|
Expected: "Hi gadmin! You've successfully authenticated..."
|
|
|
|
7. Ask me what to name the repo, then create it and push:
|
|
|
|
Create on Gitea:
|
|
curl -X POST http://192.168.0.126:3000/api/v1/user/repos \
|
|
-H "Authorization: token API_TOKEN_HERE" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{"name":"REPONAME","private":true,"auto_init":false,"default_branch":"main"}'
|
|
|
|
Init and push local code:
|
|
cd /path/to/code
|
|
git init
|
|
git remote add origin git@192.168.0.126:gadmin/REPONAME.git
|
|
git add .
|
|
git commit -m "init: initial commit from $(hostname)"
|
|
git push -u origin main
|
|
|
|
NOTES
|
|
-----
|
|
- Use LAN address 192.168.0.126:22 (not external g.pozi.co.za:2222)
|
|
- Never commit the API token to git
|
|
- Repo visibility defaults to private — confirm with owner before making public
|
|
```
|