Allow ssh

This commit is contained in:
2026-02-18 21:36:34 +01:00
parent e1b8995a72
commit 849231e9ba
3 changed files with 35 additions and 2 deletions

View File

@@ -3,6 +3,7 @@ SHARED_NETWORK_NAME=web
### Public domain for Gitea (requested subdomain: git) ### Public domain for Gitea (requested subdomain: git)
GITEA_DOMAIN=git.example.com GITEA_DOMAIN=git.example.com
GITEA_SSH_PORT=2222
### Container user mapping ### Container user mapping
GITEA_UID=1000 GITEA_UID=1000

View File

@@ -27,6 +27,7 @@ cp .env.example .env
Edit `.env` and set: Edit `.env` and set:
- `SHARED_NETWORK_NAME` to the same network name used by your main stack - `SHARED_NETWORK_NAME` to the same network name used by your main stack
- `GITEA_DOMAIN` to your git subdomain (for example `git.example.com`) - `GITEA_DOMAIN` to your git subdomain (for example `git.example.com`)
- `GITEA_SSH_PORT` to the host SSH port for Git over SSH (default in this setup: `2222`)
- Postgres credentials for a dedicated Gitea database/user - Postgres credentials for a dedicated Gitea database/user
## 2) Create Postgres DB/User (on your existing DB) ## 2) Create Postgres DB/User (on your existing DB)
@@ -90,8 +91,36 @@ docker compose logs -f gitea
docker compose logs -f gitea-runner docker compose logs -f gitea-runner
``` ```
## 8) Git over SSH
This stack exposes Gitea SSH as `${GITEA_SSH_PORT}` on the host (default `2222`).
Clone example:
```bash
git clone ssh://git@<your-gitea-domain>:2222/<owner>/<repo>.git
```
Important:
- Include `<owner>/<repo>.git` (for example `alice/my-api.git`).
- `git@<domain>/<repo>.git` is not valid for Gitea SSH clone URLs.
- If you use SCP-style syntax, include the owner and rely on `~/.ssh/config` for port:
- `git@<your-gitea-domain>:<owner>/<repo>.git`
If you want to keep using `git@<your-gitea-domain>:<owner>/<repo>.git` without specifying a port in each command, add this to your local `~/.ssh/config`:
```sshconfig
Host <your-gitea-domain>
HostName <your-gitea-domain>
User git
Port 2222
IdentitiesOnly yes
```
## Notes ## Notes
- This setup uses HTTPS via Traefik labels and Let's Encrypt from your existing stack. - This setup uses HTTPS via Traefik labels and Let's Encrypt from your existing stack.
- Git over SSH is not enabled in this compose because your current Traefik config only exposes `:80` and `:443`. HTTPS clone/push works directly. - Git over SSH is enabled by direct Docker port mapping (`${GITEA_SSH_PORT}:22`) to avoid changing your Traefik base config.
- Port `22` on the host is often already used by the server's SSH daemon. Keep `GITEA_SSH_PORT=2222` unless you intentionally move host SSH to another port.
- Gitea Actions is enabled (`GITEA__actions__ENABLED=true`). - Gitea Actions is enabled (`GITEA__actions__ENABLED=true`).
- If you ever enabled Gitea's internal SSH server before, keep `GITEA__server__START_SSH_SERVER=false` to avoid restart loops from port conflicts.

View File

@@ -9,8 +9,9 @@ services:
- GITEA__server__DOMAIN=${GITEA_DOMAIN} - GITEA__server__DOMAIN=${GITEA_DOMAIN}
- GITEA__server__ROOT_URL=https://${GITEA_DOMAIN}/ - GITEA__server__ROOT_URL=https://${GITEA_DOMAIN}/
- GITEA__server__SSH_DOMAIN=${GITEA_DOMAIN} - GITEA__server__SSH_DOMAIN=${GITEA_DOMAIN}
- GITEA__server__START_SSH_SERVER=false
- GITEA__server__HTTP_PORT=3000 - GITEA__server__HTTP_PORT=3000
- GITEA__server__SSH_PORT=22 - GITEA__server__SSH_PORT=${GITEA_SSH_PORT}
- GITEA__database__DB_TYPE=postgres - GITEA__database__DB_TYPE=postgres
- GITEA__database__HOST=${GITEA_DB_HOST}:${GITEA_DB_PORT} - GITEA__database__HOST=${GITEA_DB_HOST}:${GITEA_DB_PORT}
- GITEA__database__NAME=${GITEA_DB_NAME} - GITEA__database__NAME=${GITEA_DB_NAME}
@@ -24,6 +25,8 @@ services:
- gitea_data:/data - gitea_data:/data
- /etc/timezone:/etc/timezone:ro - /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro - /etc/localtime:/etc/localtime:ro
ports:
- "${GITEA_SSH_PORT}:22"
labels: labels:
- traefik.enable=true - traefik.enable=true
- traefik.docker.network=${SHARED_NETWORK_NAME} - traefik.docker.network=${SHARED_NETWORK_NAME}