- Step-by-step instructions for key generation - How to add public key to Gitea - Testing SSH connection - Integration with init-project workflow - Troubleshooting tips
2.1 KiB
SSH Setup for Gitea
To push code to Gitea from your VPS, you need to set up SSH authentication.
Generate SSH Key
On your VPS, run:
ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -N ""
This creates:
~/.ssh/id_ed25519(private key)~/.ssh/id_ed25519.pub(public key)
Add Public Key to Gitea
-
Display your public key:
cat ~/.ssh/id_ed25519.pub -
Copy the output (entire line starting with
ssh-ed25519) -
Go to Gitea: http://100.120.125.113:3000/user/settings/keys
-
Click "Add Key"
-
Paste your public key
-
Click "Add Key"
Test SSH Connection
Verify it works:
ssh -T git@100.120.125.113
You should see a message like:
Hi pdm! You've successfully authenticated, but Gitea does not provide shell access.
Using SSH with Git
When you init-project, it automatically sets up SSH remotes:
init-project my-app
cd my-app
git remote -v
# Should show: origin git@100.120.125.113:pdm/my-app.git (fetch)
Now when you push:
git push origin main
No password needed - SSH key handles authentication!
Troubleshooting
SSH key not being used:
# Check SSH agent is running
eval "$(ssh-agent -s)"
# Add your key
ssh-add ~/.ssh/id_ed25519
Still getting authentication errors:
- Verify key is in Gitea (http://100.120.125.113:3000/user/settings/keys)
- Check file permissions:
chmod 600 ~/.ssh/id_ed25519 - Test connection:
ssh -T git@100.120.125.113
Need different key per VPS: Generate separate keys:
ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519_vps-name -N ""
Add to Gitea with a descriptive name (e.g., "vps-name-key")
One-Time Setup Script
To automate this on a new VPS:
#!/bin/bash
# Auto-setup SSH for Gitea
mkdir -p ~/.ssh
ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -N ""
echo ""
echo "✅ SSH key generated!"
echo "Add this to Gitea (http://100.120.125.113:3000/user/settings/keys):"
cat ~/.ssh/id_ed25519.pub
echo ""
echo "Test with: ssh -T git@100.120.125.113"
Save as ~/.homelab-scripts/setup-ssh.sh and run: bash ~/.homelab-scripts/setup-ssh.sh