From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NO_DNS_FOR_FROM,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 Received: from integral2.. (unknown [36.80.217.41]) by gnuweeb.org (Postfix) with ESMTPSA id 42E597E3B5; Fri, 15 Apr 2022 17:49:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1650044995; bh=gL+WL88AtlFeEWLdUoHoPImzh5TVDNieQVY6rT+M9QM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ppQyg2DpA+XnnWjjplcHHdDF3x1mRVzvQTcSR/qZIhzXQJ4L82v52TWWMKyD6a1s+ JEhggQbsfUdfQ/IFOEoTBqe1iRoYEsGAOLNyMFQw39FqjokHSxYx1kUVlJKSeRheBQ 4WMOc4spF/78JJaav1ZKYwRersZpweM1Xh8l3gCVCy0porFmCBb1GZh8FxIM943eT3 13rl48VBwJLS921FK7liAwMujfSOEiBxsfykDfkmaEF6BBXoaB3TSFFhNtR+NqvjER /EGJTUkNNzIRXXvZsjSGY+IbjHTOB6HSABIk/I8K7RQPz9vQLs4Xnvm7iPIatAZnZo 7/dy9P5W3Pm8w== From: Ammar Faizi To: GNU/Weeb Mailing List Cc: Ammar Faizi , Hazmi Alfarizqi , Alviro Iskandar Setiawan Subject: [PATCH server-a001 v2 1/1] Apply default SSH config and add public keys Date: Sat, 16 Apr 2022 00:49:40 +0700 Message-Id: <20220415174940.38497-2-ammarfaizi2@gnuweeb.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220415174940.38497-1-ammarfaizi2@gnuweeb.org> References: <20220415174940.38497-1-ammarfaizi2@gnuweeb.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 1) Set the default port to 48589, don't use port 22 since we will inevitably get brute-force SSH attack from random botnets. Even if it's not really a concern if we're using a private key for the auth, let's not spam our auth log with many login failed lines. 2) Add maintainers' SSH public keys to the root and main user. Let us login from the outside world with a key auth. Signed-off-by: Ammar Faizi --- Dockerfile | 16 ++++- etc/ssh/sshd_config | 123 +++++++++++++++++++++++++++++++++++++++ ssh_keys/authorized_keys | 3 + 3 files changed, 139 insertions(+), 3 deletions(-) create mode 100644 etc/ssh/sshd_config create mode 100644 ssh_keys/authorized_keys diff --git a/Dockerfile b/Dockerfile index 58870ef..5e59701 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,9 +29,19 @@ RUN apt-key adv --fetch-keys https://nginx.org/keys/nginx_signing.key \ && apt-get update \ && apt-get -y --no-install-recommends install openssh-server nginx -# Mark port 22/tcp is to be exposed -EXPOSE 22/tcp +# Mark port 48589/tcp is to be exposed +EXPOSE 48589/tcp + +# Apply SSH config and add public keys +COPY etc/ssh/sshd_config /etc/ssh/sshd_config +RUN rm -rf /root/.ssh /home/${mainUser}/.ssh +COPY ssh_keys /root/.ssh +COPY ssh_keys /home/${mainUser}/.ssh +RUN chown -R root:root /root/.ssh \ + && chmod -R 600 /root/.ssh \ + && chown -R ${mainUser}:${mainUser} /home/${mainUser}/.ssh \ + && chmod -R 600 /home/${mainUser}/.ssh COPY docker-entrypoint.sh / ENTRYPOINT [ "/docker-entrypoint.sh" ] -CMD [ "tail", "-f", "/dev/null" ] \ No newline at end of file +CMD [ "tail", "-f", "/dev/null" ] diff --git a/etc/ssh/sshd_config b/etc/ssh/sshd_config new file mode 100644 index 0000000..9f81626 --- /dev/null +++ b/etc/ssh/sshd_config @@ -0,0 +1,123 @@ +# $OpenBSD: sshd_config,v 1.103 2018/04/09 20:41:22 tj Exp $ + +# This is the sshd server system-wide configuration file. See +# sshd_config(5) for more information. + +# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin + +# The strategy used for options in the default sshd_config shipped with +# OpenSSH is to specify options with their default value where +# possible, but leave them commented. Uncommented options override the +# default value. + +Include /etc/ssh/sshd_config.d/*.conf + +Port 48589 +#AddressFamily any +#ListenAddress 0.0.0.0 +#ListenAddress :: + +#HostKey /etc/ssh/ssh_host_rsa_key +#HostKey /etc/ssh/ssh_host_ecdsa_key +#HostKey /etc/ssh/ssh_host_ed25519_key + +# Ciphers and keying +#RekeyLimit default none + +# Logging +#SyslogFacility AUTH +#LogLevel INFO + +# Authentication: + +#LoginGraceTime 2m +PermitRootLogin prohibit-password +#StrictModes yes +#MaxAuthTries 6 +#MaxSessions 10 + +#PubkeyAuthentication yes + +# Expect .ssh/authorized_keys2 to be disregarded by default in future. +#AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2 + +#AuthorizedPrincipalsFile none + +#AuthorizedKeysCommand none +#AuthorizedKeysCommandUser nobody + +# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts +#HostbasedAuthentication no +# Change to yes if you don't trust ~/.ssh/known_hosts for +# HostbasedAuthentication +#IgnoreUserKnownHosts no +# Don't read the user's ~/.rhosts and ~/.shosts files +#IgnoreRhosts yes + +# To disable tunneled clear text passwords, change to no here! +PasswordAuthentication no +#PermitEmptyPasswords no + +# Change to yes to enable challenge-response passwords (beware issues with +# some PAM modules and threads) +ChallengeResponseAuthentication no + +# Kerberos options +#KerberosAuthentication no +#KerberosOrLocalPasswd yes +#KerberosTicketCleanup yes +#KerberosGetAFSToken no + +# GSSAPI options +#GSSAPIAuthentication no +#GSSAPICleanupCredentials yes +#GSSAPIStrictAcceptorCheck yes +#GSSAPIKeyExchange no + +# Set this to 'yes' to enable PAM authentication, account processing, +# and session processing. If this is enabled, PAM authentication will +# be allowed through the ChallengeResponseAuthentication and +# PasswordAuthentication. Depending on your PAM configuration, +# PAM authentication via ChallengeResponseAuthentication may bypass +# the setting of "PermitRootLogin without-password". +# If you just want the PAM account and session checks to run without +# PAM authentication, then enable this but set PasswordAuthentication +# and ChallengeResponseAuthentication to 'no'. +UsePAM yes + +#AllowAgentForwarding yes +#AllowTcpForwarding yes +#GatewayPorts no +X11Forwarding yes +#X11DisplayOffset 10 +#X11UseLocalhost yes +#PermitTTY yes +PrintMotd no +#PrintLastLog yes +#TCPKeepAlive yes +#PermitUserEnvironment no +#Compression delayed +ClientAliveInterval 15 +#ClientAliveCountMax 3 +#UseDNS no +#PidFile /var/run/sshd.pid +#MaxStartups 10:30:100 +#PermitTunnel no +#ChrootDirectory none +#VersionAddendum none + +# no default banner path +#Banner none + +# Allow client to pass locale environment variables +AcceptEnv LANG LC_* + +# override default of no subsystems +Subsystem sftp /usr/lib/openssh/sftp-server + +# Example of overriding settings on a per-user basis +#Match User anoncvs +# X11Forwarding no +# AllowTcpForwarding no +# PermitTTY no +# ForceCommand cvs server diff --git a/ssh_keys/authorized_keys b/ssh_keys/authorized_keys new file mode 100644 index 0000000..84bd5ca --- /dev/null +++ b/ssh_keys/authorized_keys @@ -0,0 +1,3 @@ +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIK4MbVLR2847dHKdtr4M0p9g3M1Q9eiv4Lhr1x1x6RJ1 hzmi@gnuweeb.org +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKhFfg8XTsIp3KM93LeLxOPtR/fGozCgtND9ySLbMUSA ammarfaizi2@gmail.com +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJrp2IqgUsn1nwMMSS5QA56pFGb8RObcbgQVUiqBvg4V alviro.iskandar@gmail.com -- Ammar Faizi