From 75d44143863e90a7aeff30a3f40128f144df94dd Mon Sep 17 00:00:00 2001 From: Christopher Thomas Date: Sun, 7 Jul 2019 03:57:53 +0200 Subject: Implement the ability to change the ssh port to match what is in the gitea config (#7286) * - rearrange the templates to make it more logical because now ssh_config is a template - implemented the updating of the port to the same as the port sent to the gitea config * change the filename back --- docker/root/etc/s6/openssh/setup | 7 +++++++ docker/root/etc/ssh/sshd_config | 33 --------------------------------- docker/root/etc/templates/sshd_config | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 33 deletions(-) delete mode 100644 docker/root/etc/ssh/sshd_config create mode 100644 docker/root/etc/templates/sshd_config (limited to 'docker/root') diff --git a/docker/root/etc/s6/openssh/setup b/docker/root/etc/s6/openssh/setup index f8ef816a95..10d195b74f 100755 --- a/docker/root/etc/s6/openssh/setup +++ b/docker/root/etc/s6/openssh/setup @@ -24,6 +24,13 @@ if [ ! -f /data/ssh/ssh_host_ecdsa_key ]; then ssh-keygen -t ecdsa -b 256 -f /data/ssh/ssh_host_ecdsa_key -N "" > /dev/null fi +if [ -d /etc/ssh ]; then + SSH_PORT=${SSH_PORT:-"22"} \ + envsubst < /etc/templates/sshd_config > /etc/ssh/sshd_config + + chmod 0644 /etc/ssh/sshd_config +fi + chown root:root /data/ssh/* chmod 0700 /data/ssh chmod 0600 /data/ssh/* diff --git a/docker/root/etc/ssh/sshd_config b/docker/root/etc/ssh/sshd_config deleted file mode 100644 index 6af082c419..0000000000 --- a/docker/root/etc/ssh/sshd_config +++ /dev/null @@ -1,33 +0,0 @@ -Port 22 -Protocol 2 - -AddressFamily any -ListenAddress 0.0.0.0 -ListenAddress :: - -LogLevel INFO - -HostKey /data/ssh/ssh_host_ed25519_key -HostKey /data/ssh/ssh_host_rsa_key -HostKey /data/ssh/ssh_host_dsa_key -HostKey /data/ssh/ssh_host_ecdsa_key - -AuthorizedKeysFile .ssh/authorized_keys - -UseDNS no -AllowAgentForwarding no -AllowTcpForwarding no -PrintMotd no - -PermitUserEnvironment yes -PermitRootLogin no -ChallengeResponseAuthentication no -PasswordAuthentication no -PermitEmptyPasswords no - -AllowUsers git - -Banner none -Subsystem sftp /usr/lib/ssh/sftp-server - -AcceptEnv GIT_PROTOCOL \ No newline at end of file diff --git a/docker/root/etc/templates/sshd_config b/docker/root/etc/templates/sshd_config new file mode 100644 index 0000000000..ba92e236e1 --- /dev/null +++ b/docker/root/etc/templates/sshd_config @@ -0,0 +1,33 @@ +Port ${SSH_PORT} +Protocol 2 + +AddressFamily any +ListenAddress 0.0.0.0 +ListenAddress :: + +LogLevel INFO + +HostKey /data/ssh/ssh_host_ed25519_key +HostKey /data/ssh/ssh_host_rsa_key +HostKey /data/ssh/ssh_host_dsa_key +HostKey /data/ssh/ssh_host_ecdsa_key + +AuthorizedKeysFile .ssh/authorized_keys + +UseDNS no +AllowAgentForwarding no +AllowTcpForwarding no +PrintMotd no + +PermitUserEnvironment yes +PermitRootLogin no +ChallengeResponseAuthentication no +PasswordAuthentication no +PermitEmptyPasswords no + +AllowUsers git + +Banner none +Subsystem sftp /usr/lib/ssh/sftp-server + +AcceptEnv GIT_PROTOCOL \ No newline at end of file -- cgit v1.2.3