Skip to content

Commit b850342

Browse files
authored
Merge pull request #2093 from appvia/change-sshd-listen-port
Allow modifying the sshd listen port
2 parents a40c276 + be2d9a8 commit b850342

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
@@ -870,7 +870,8 @@ Below is the complete list of available options that can be used to customize yo
870870
| `GITLAB_BACKUP_TIME` | Set a time for the automatic backups in `HH:MM` format. Defaults to `04:00`. |
871871
| `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) |
872872
| `GITLAB_SSH_HOST` | The ssh host. Defaults to **GITLAB_HOST**. |
873-
| `GITLAB_SSH_PORT` | The ssh port number. Defaults to `22`. |
873+
| `GITLAB_SSH_LISTEN_PORT` | The ssh port for SSHD to listen on. Defaults to `22` |
874+
| `GITLAB_SSH_PORT` | The ssh port number. Defaults to `$GITLAB_SSH_LISTEN_PORT`. |
874875
| `GITLAB_RELATIVE_URL_ROOT` | The relative url of the GitLab server, e.g. `/git`. No default. |
875876
| `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. |
876877
| `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}
@@ -97,7 +98,7 @@ GITLAB_WEBHOOK_TIMEOUT=${GITLAB_WEBHOOK_TIMEOUT:-10}
9798

9899
GITLAB_WORKHORSE_TIMEOUT=${GITLAB_WORKHORSE_TIMEOUT:-5m0s}
99100

100-
# OBJECTSTORE
101+
# OBJECTSTORE
101102
GITLAB_OBJECT_STORE_CONNECTION_PROVIDER=${GITLAB_OBJECT_STORE_CONNECTION_PROVIDER:-AWS}
102103
AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID:-AWS_ACCESS_KEY_ID}
103104
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
@@ -1511,12 +1511,17 @@ generate_ssh_host_keys() {
15111511
chmod 0644 ${GITLAB_DATA_DIR}/ssh/*.pub
15121512
}
15131513

1514+
update_ssh_listen_port() {
1515+
sed -i "s|#Port 22|Port ${GITLAB_SSH_LISTEN_PORT}|g" /etc/ssh/sshd_config
1516+
}
1517+
15141518
initialize_system() {
15151519
map_uidgid
15161520
initialize_logdir
15171521
initialize_datadir
15181522
update_ca_certificates
15191523
generate_ssh_host_keys
1524+
update_ssh_listen_port
15201525
install_configuration_templates
15211526
rm -rf /var/run/supervisor.sock
15221527
}
@@ -1611,6 +1616,7 @@ configure_gitlab() {
16111616
GITLAB_RELATIVE_URL_ROOT \
16121617
GITLAB_HTTPS \
16131618
GITLAB_SSH_HOST \
1619+
GITLAB_SSH_LISTEN_PORT \
16141620
GITLAB_SSH_PORT \
16151621
GITLAB_SIGNUP_ENABLED \
16161622
GITLAB_IMPERSONATION_ENABLED \

0 commit comments

Comments
 (0)