4.7 KiB
4.7 KiB
Gitea SSH on Unraid (reusable)
Use this for any repo on your Gitea (git.masengr.com) from the Unraid host — photo site, qBittorrent configs, etc.
Why this setup
| Problem | Cause | Fix |
|---|---|---|
| HTTPS keeps asking for a password | 2FA → need a PAT, not account password | Prefer SSH |
ssh git.masengr.com asks for password on port 22 |
Port 22 is Unraid’s SSH, not Gitea | Use Gitea’s mapped port |
git.masengr.com:2222 → connection refused |
Public DNS/SWAG doesn’t expose 2222 | From Unraid, use 127.0.0.1 + Gitea SSH port |
Your Gitea container typically publishes SSH like:
0.0.0.0:2222->22/tcp
Confirm anytime:
docker ps --format 'table {{.Names}}\t{{.Ports}}' | grep -i gitea
Use whatever host port maps to container 22 (often 2222).
One-time: create a user SSH key (all your repos)
On Unraid:
ssh-keygen -t ed25519 -C "unraid-gitea" -f ~/.ssh/gitea_unraid -N ""
cat ~/.ssh/gitea_unraid.pub
In Gitea (web UI):
- Avatar → Settings → SSH / GPG Keys → Add Key
- Title:
unraid-gitea - Paste the entire
.publine (ssh-ed25519 AAAA... unraid-gitea) - Save
Use a user SSH key (works for every repo your user can access).
Use a Deploy Key only when you want one repo, read-only.
One-time: SSH config on Unraid
Point the hostname at local Gitea SSH (same machine):
mkdir -p ~/.ssh
cat > ~/.ssh/config <<'EOF'
Host git.masengr.com
HostName 127.0.0.1
User git
Port 2222
IdentityFile ~/.ssh/gitea_unraid
IdentitiesOnly yes
EOF
chmod 700 ~/.ssh
chmod 600 ~/.ssh/config ~/.ssh/gitea_unraid
chmod 644 ~/.ssh/gitea_unraid.pub
If docker ps shows a different host port than 2222, change Port to match.
Test (success looks like this)
ssh -T git@git.masengr.com
Expected:
Hi there, YOUR_USERNAME! You've successfully authenticated with the key named gitea_unraid, but Gitea does not provide shell access.
- No password prompt = good
- Post-quantum /
known_hostswarnings can be ignored if auth succeeds - If you see
Connection refusedongit.masengr.com:2222without this config, you were hitting the public IP — keepHostName 127.0.0.1
Per repo: use an SSH remote
cd /path/to/clone
git remote set-url origin git@git.masengr.com:YOUR_NAMESPACE/YOUR_REPO.git
git remote -v
git pull
Examples:
git@git.masengr.com:Michael-A-Sloan/Neon-Photos_Site.git
git@git.masengr.com:Michael-A-Sloan/qBittorrent-Enhanced-Edition-docker-with-vpn.git
Clone fresh with SSH:
cd /mnt/user/appdata
git clone git@git.masengr.com:Michael-A-Sloan/SOME_REPO.git some-folder
Day-to-day
cd /path/to/repo
git pull
# then whatever that project uses, e.g.:
# sh scripts/deploy.sh
No PAT prompt for git over SSH.
Troubleshooting
Still asks for password
ssh -vT git@git.masengr.com 2>&1 | grep -iE 'Offering public key|Authentications that can continue|Authenticated|Connection'
Check:
- Pubkey is on user SSH keys in Gitea (exact match to
cat ~/.ssh/gitea_unraid.pub) Portmatchesdocker pshost mappingHostNameis127.0.0.1(or192.168.10.3) when running on Unraid- Remote is SSH, not HTTPS:
git remote -vshould showgit@git.masengr.com:...
Connection refused
- Wrong port, or
HostNameis the public DNS without 2222 forwarded - On Unraid → use
127.0.0.1+ correctPort
Remake the key
rm -f ~/.ssh/gitea_unraid ~/.ssh/gitea_unraid.pub
# Delete old key in Gitea UI, then redo "create key" + paste .pub steps above
HTTPS PAT (only if you must avoid SSH)
git config --global credential.helper store
# git pull once; username = Gitea user; password = PAT (not account password)
chmod 600 /root/.git-credentials
SSH is preferred on Unraid for this Gitea.
What not to do
- Don’t put a Gitea PAT in app
.envor Docker template variables - Don’t use Unraid host port 22 for Gitea if Unraid already owns SSH there
- Don’t expect
git.masengr.com:2222from the internet unless you intentionally port-forward it
Quick checklist (new machine / new Unraid flash)
ssh-keygen→~/.ssh/gitea_unraid- Paste
.pubinto Gitea user SSH keys ~/.ssh/configwithHostName 127.0.0.1,Port 2222(or your map)ssh -T git@git.masengr.comgreets yougit remote set-url origin git@git.masengr.com:USER/REPO.gitgit pullwith no password