Skip to content

Commit 4e6c948

Browse files
committed
Fix issue whereby setting SSH_PORT, for the purpose of constructing a superficial git-clone URL, would implicitly also set SSH_LISTEN_PORT that the SSH service listens on, if the latter is not explicitly configured.
This is a corrective fix to prior issues go-gitea#8453 and go-gitea#8477.
1 parent c84174b commit 4e6c948

File tree

6 files changed

+12
-11
lines changed

6 files changed

+12
-11
lines changed

docker/root/etc/s6/gitea/setup

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ if [ ! -f ${GITEA_CUSTOM}/conf/app.ini ]; then
3030
HTTP_PORT=${HTTP_PORT:-"3000"} \
3131
ROOT_URL=${ROOT_URL:-""} \
3232
DISABLE_SSH=${DISABLE_SSH:-"false"} \
33-
SSH_PORT=${SSH_PORT:-"22"} \
34-
SSH_LISTEN_PORT=${SSH_LISTEN_PORT:-"${SSH_PORT}"} \
33+
SSH_LISTEN_PORT=${SSH_LISTEN_PORT:-"22"} \
34+
SSH_PORT=${SSH_PORT:-"${SSH_LISTEN_PORT}"} \
3535
LFS_START_SERVER=${LFS_START_SERVER:-"false"} \
3636
DB_TYPE=${DB_TYPE:-"sqlite3"} \
3737
DB_HOST=${DB_HOST:-"localhost:3306"} \

docker/root/etc/s6/openssh/setup

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ if [ ! -f /data/ssh/ssh_host_ecdsa_key ]; then
2525
fi
2626

2727
if [ -d /etc/ssh ]; then
28-
SSH_PORT=${SSH_PORT:-"22"} \
29-
SSH_LISTEN_PORT=${SSH_LISTEN_PORT:-"${SSH_PORT}"} \
28+
SSH_LISTEN_PORT=${SSH_LISTEN_PORT:-"22"} \
29+
SSH_PORT=${SSH_PORT:-"${SSH_LISTEN_PORT}"} \
3030
envsubst < /etc/templates/sshd_config > /etc/ssh/sshd_config
3131

3232
chmod 0644 /etc/ssh/sshd_config

docs/content/doc/advanced/config-cheat-sheet.en-us.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,9 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`.
161161
- `DISABLE_SSH`: **false**: Disable SSH feature when it's not available.
162162
- `START_SSH_SERVER`: **false**: When enabled, use the built-in SSH server.
163163
- `SSH_DOMAIN`: **%(DOMAIN)s**: Domain name of this server, used for displayed clone URL.
164-
- `SSH_PORT`: **22**: SSH port displayed in clone URL.
165164
- `SSH_LISTEN_HOST`: **0.0.0.0**: Listen address for the built-in SSH server.
166-
- `SSH_LISTEN_PORT`: **%(SSH\_PORT)s**: Port for the built-in SSH server.
165+
- `SSH_LISTEN_PORT`: **22**: Port for the built-in SSH server.
166+
- `SSH_PORT`: **%(SSH\_LISTEN\_PORT)s**: SSH port displayed in clone URL.
167167
- `OFFLINE_MODE`: **false**: Disables use of CDN for static files and Gravatar for profile pictures.
168168
- `DISABLE_ROUTER_LOG`: **false**: Mute printing of the router log.
169169
- `CERT_FILE`: **custom/https/cert.pem**: Cert file path used for HTTPS.

docs/content/doc/advanced/config-cheat-sheet.zh-cn.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ menu:
5959
- `HTTP_PORT`: HTTP 监听端口。
6060
- `DISABLE_SSH`: 是否禁用SSH。
6161
- `START_SSH_SERVER`: 是否启用内部SSH服务器。
62-
- `SSH_PORT`: SSH端口,默认为 `22`
62+
- `SSH_LISTEN_PORT`: SSH端口,默认为 `22`
63+
- `SSH_PORT`: 克隆URL中显示的SSH端口,默认为 `SSH_LISTEN_PORT`
6364
- `OFFLINE_MODE`: 针对静态和头像文件禁用 CDN。
6465
- `DISABLE_ROUTER_LOG`: 关闭日志中的路由日志。
6566
- `CERT_FILE`: 启用HTTPS的证书文件。

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,8 @@ You can configure some of Gitea's settings via environment variables:
244244
* `APP_NAME`: **"Gitea: Git with a cup of tea"**: Application name, used in the page title.
245245
* `RUN_MODE`: **dev**: For performance and other purposes, change this to `prod` when deployed to a production environment.
246246
* `SSH_DOMAIN`: **localhost**: Domain name of this server, used for the displayed clone URL in Gitea's UI.
247-
* `SSH_PORT`: **22**: SSH port displayed in clone URL.
248-
* `SSH_LISTEN_PORT`: **%(SSH\_PORT)s**: Port for the built-in SSH server.
247+
* `SSH_LISTEN_PORT`: **22**: Port for the built-in SSH server.
248+
* `SSH_PORT`: **%(SSH\_LISTEN\_PORT)s**: SSH port displayed in clone URL.
249249
* `DISABLE_SSH`: **false**: Disable SSH feature when it's not available.
250250
* `HTTP_PORT`: **3000**: HTTP listen port.
251251
* `ROOT_URL`: **""**: Overwrite the automatically generated public URL. This is useful if the internal and the external URL don't match (e.g. in Docker).

modules/setting/setting.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -654,8 +654,8 @@ func NewContext() {
654654
}
655655

656656
SSH.KeygenPath = sec.Key("SSH_KEYGEN_PATH").MustString("ssh-keygen")
657-
SSH.Port = sec.Key("SSH_PORT").MustInt(22)
658-
SSH.ListenPort = sec.Key("SSH_LISTEN_PORT").MustInt(SSH.Port)
657+
SSH.ListenPort = sec.Key("SSH_LISTEN_PORT").MustInt(22)
658+
SSH.Port = sec.Key("SSH_PORT").MustInt(SSH.ListenPort)
659659

660660
// When disable SSH, start builtin server value is ignored.
661661
if SSH.Disabled {

0 commit comments

Comments
 (0)