Skip to content

Commit be2d9a8

Browse files
committed
Allow modifying the sshd listen port
1 parent dcf9e25 commit be2d9a8

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,8 @@ Below is the complete list of available options that can be used to customize yo
864864
| `GITLAB_BACKUP_TIME` | Set a time for the automatic backups in `HH:MM` format. Defaults to `04:00`. |
865865
| `GITLAB_BACKUP_SKIP` | Specified sections are skipped by the backups. Defaults to empty, i.e. `lfs,uploads`. [See](http://doc.gitlab.com/ce/raketasks/backup_restore.html#create-a-backup-of-the-gitlab-system) |
866866
| `GITLAB_SSH_HOST` | The ssh host. Defaults to **GITLAB_HOST**. |
867-
| `GITLAB_SSH_PORT` | The ssh port number. Defaults to `22`. |
867+
| `GITLAB_SSH_LISTEN_PORT` | The ssh port for SSHD to listen on. Defaults to `22` |
868+
| `GITLAB_SSH_PORT` | The ssh port number. Defaults to `$GITLAB_SSH_LISTEN_PORT`. |
868869
| `GITLAB_RELATIVE_URL_ROOT` | The relative url of the GitLab server, e.g. `/git`. No default. |
869870
| `GITLAB_TRUSTED_PROXIES` | Add IP address reverse proxy to trusted proxy list, otherwise users will appear signed in from that address. Currently only a single entry is permitted. No defaults. |
870871
| `GITLAB_REGISTRY_ENABLED` | Enables the GitLab Container Registry. Defaults to `false`. |

assets/runtime/env-defaults

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ fi
2626
## SSH
2727
GITLAB_SSH_HOST=${GITLAB_SSH_HOST:-$GITLAB_HOST}
2828
GITLAB_SSH_PORT=${GITLAB_SSH_PORT:-$GITLAB_SHELL_SSH_PORT} # for backwards compatibility
29-
GITLAB_SSH_PORT=${GITLAB_SSH_PORT:-22}
29+
GITLAB_SSH_LISTEN_PORT=${GITLAB_SSH_LISTEN_PORT:-22}
30+
GITLAB_SSH_PORT=${GITLAB_SSH_PORT:-$GITLAB_SSH_LISTEN_PORT}
3031

3132
NGINX_HSTS_ENABLED=${NGINX_HSTS_ENABLED:-$GITLAB_HTTPS_HSTS_ENABLED} # backward compatibility
3233
NGINX_HSTS_ENABLED=${NGINX_HSTS_ENABLED:-true}
@@ -89,7 +90,7 @@ GITLAB_WEBHOOK_TIMEOUT=${GITLAB_WEBHOOK_TIMEOUT:-10}
8990

9091
GITLAB_WORKHORSE_TIMEOUT=${GITLAB_WORKHORSE_TIMEOUT:-5m0s}
9192

92-
# OBJECTSTORE
93+
# OBJECTSTORE
9394
GITLAB_OBJECT_STORE_CONNECTION_PROVIDER=${GITLAB_OBJECT_STORE_CONNECTION_PROVIDER:-AWS}
9495
AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID:-AWS_ACCESS_KEY_ID}
9596
AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY:-AWS_SECRET_ACCESS_KEY}

assets/runtime/functions

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,12 +1473,17 @@ generate_ssh_host_keys() {
14731473
chmod 0644 ${GITLAB_DATA_DIR}/ssh/*.pub
14741474
}
14751475

1476+
update_ssh_listen_port() {
1477+
sed -i "s|#Port 22|Port ${GITLAB_SSH_LISTEN_PORT}|g" /etc/ssh/sshd_config
1478+
}
1479+
14761480
initialize_system() {
14771481
map_uidgid
14781482
initialize_logdir
14791483
initialize_datadir
14801484
update_ca_certificates
14811485
generate_ssh_host_keys
1486+
update_ssh_listen_port
14821487
install_configuration_templates
14831488
rm -rf /var/run/supervisor.sock
14841489
}
@@ -1573,6 +1578,7 @@ configure_gitlab() {
15731578
GITLAB_RELATIVE_URL_ROOT \
15741579
GITLAB_HTTPS \
15751580
GITLAB_SSH_HOST \
1581+
GITLAB_SSH_LISTEN_PORT \
15761582
GITLAB_SSH_PORT \
15771583
GITLAB_SIGNUP_ENABLED \
15781584
GITLAB_IMPERSONATION_ENABLED \

0 commit comments

Comments
 (0)