Skip to content

Commit 1c230f6

Browse files
pat-slunny
andauthored
update ssh passthrough (#14403)
Co-authored-by: Lunny Xiao <[email protected]>
1 parent 83c920d commit 1c230f6

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

docs/content/doc/installation/with-docker.en-us.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -345,19 +345,23 @@ ports:
345345
- "127.0.0.1:2222:22"
346346
```
347347

348-
In addition, `/home/git/.ssh/authorized_keys` on the host needs to be modified. It needs to act in the same way as `authorized_keys` within the Gitea container. Therefore add
348+
In addition, `/home/git/.ssh/authorized_keys` on the host needs to be modified. It needs to act in the same way as `authorized_keys` within the Gitea container. Therefore add the public key of the key you created above ("Gitea Host Key") to `~/git/.ssh/authorized_keys`.
349+
This can be done via `echo "$(cat /home/git/.ssh/id_rsa.pub)" >> /home/git/.ssh/authorized_keys`.
350+
Important: The pubkey from the `git` user needs to be added "as is" while all other pubkeys added via the Gitea web interface will be prefixed with `command="/app [...]`.
349351

350-
```bash
351-
command="/app/gitea/gitea --config=/data/gitea/conf/app.ini serv key-1",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-rsa <YOUR_SSH_PUBKEY>
352-
```
352+
The file should then look somewhat like
353353

354-
and replace `<YOUR_SSH_PUBKEY>` with a valid SSH public key of yours.
354+
```bash
355+
# SSH pubkey from git user
356+
ssh-rsa <Gitea Host Key>
355357

356-
In addition the public key of the `git` user on the host needs to be added to `/home/git/.ssh/authorized_keys` so authentication against the container can succeed: `echo "$(cat /home/git/.ssh/id_rsa.pub)" >> /home/git/.ssh/authorized_keys`.
358+
# other keys from users
359+
command="/app/gitea/gitea --config=/data/gitea/conf/app.ini serv key-1",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty <user pubkey>
360+
```
357361

358362
Here is a detailed explanation what is happening when a SSH request is made:
359363

360-
1. A SSH request is made against the host using the `git` user, e.g. `git clone git@domain:user/repo.git`.
364+
1. A SSH request is made against the host (usually port 22) using the `git` user, e.g. `git clone git@domain:user/repo.git`.
361365
2. In `/home/git/.ssh/authorized_keys` , the command executes the `/app/gitea/gitea` script.
362366
3. `/app/gitea/gitea` forwards the SSH request to port 2222 which is mapped to the SSH port (22) of the container.
363367
4. Due to the existence of the public key of the `git` user in `/home/git/.ssh/authorized_keys` the authentication host → container succeeds and the SSH request get forwarded to Gitea running in the docker container.

0 commit comments

Comments
 (0)