Skip to content

Commit 3197092

Browse files
committed
Create symlinks in /etc/ssh pointing to /etc/gitlab for SSH private keys
The current gitlab Docker image creates SSH host keys during build in /etc/ssh when installing openssh-server. These keys are not used. Instead, the SSH host keys for Gitlab are generated by the wrapper script and stored in /etc/gitlab. Previously, the wrapper script overwrote the unused SSH public host keys in /etc/ssh with symlinks pointing to the keys used in /etc/gitlab. The SSH private keys were left untouched. Thus, there were SSH private keys in /etc/ssh that were not used and the corresponding public keys in /etc/ssh were symlinks to /etc/gitlab and the private and public keys did not match. Since this is could be confusing for adminstrators, this commit alters the wrapper script so that the unused SSH private keys in /etc/ssh are replaced with symlinks to the private keys used in /etc/gitlab.
1 parent 77527d4 commit 3197092

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

docker/assets/wrapper

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ if [[ ! -f /etc/gitlab/ssh_host_rsa_key ]]; then
105105
fi
106106
# sshd loads the keys from /etc/gitlab, but the GitLab backend looks for keys
107107
# from within /etc/ssh
108+
ln -fs /etc/gitlab/ssh_host_rsa_key /etc/ssh/ssh_host_rsa_key
108109
ln -fs /etc/gitlab/ssh_host_rsa_key.pub /etc/ssh/ssh_host_rsa_key.pub
109110

110111
if [[ ! -f /etc/gitlab/ssh_host_ecdsa_key ]]; then
@@ -114,6 +115,7 @@ if [[ ! -f /etc/gitlab/ssh_host_ecdsa_key ]]; then
114115
fi
115116
# sshd loads the keys from /etc/gitlab, but the GitLab backend looks for keys
116117
# from within /etc/ssh
118+
ln -fs /etc/gitlab/ssh_host_ecdsa_key /etc/ssh/ssh_host_ecdsa_key
117119
ln -fs /etc/gitlab/ssh_host_ecdsa_key.pub /etc/ssh/ssh_host_ecdsa_key.pub
118120

119121
if [[ ! -f /etc/gitlab/ssh_host_ed25519_key ]]; then
@@ -123,6 +125,7 @@ if [[ ! -f /etc/gitlab/ssh_host_ed25519_key ]]; then
123125
fi
124126
# sshd loads the keys from /etc/gitlab, but the GitLab backend looks for keys
125127
# from within /etc/ssh
128+
ln -fs /etc/gitlab/ssh_host_ed25519_key /etc/ssh/ssh_host_ed25519_key
126129
ln -fs /etc/gitlab/ssh_host_ed25519_key.pub /etc/ssh/ssh_host_ed25519_key.pub
127130

128131

0 commit comments

Comments
 (0)