public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH server-a001 v2 0/1] Apply default SSH config and add public keys
@ 2022-04-15 17:49 Ammar Faizi
  2022-04-15 17:49 ` [PATCH server-a001 v2 1/1] " Ammar Faizi
  2022-04-15 17:55 ` [PATCH server-a001 v2 0/1] " Alviro Iskandar Setiawan
  0 siblings, 2 replies; 3+ messages in thread
From: Ammar Faizi @ 2022-04-15 17:49 UTC (permalink / raw)
  To: GNU/Weeb Mailing List
  Cc: Ammar Faizi, Hazmi Alfarizqi, Alviro Iskandar Setiawan

Hi,

This is v2. Just a single patch here. This does 2 dependent things:

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.

Please review!

## Changelog

Link v1: https://lore.gnuweeb.org/gwml/[email protected]
v1 -> v2:
  - Really disable PasswordAuthentication (comment from Alviro).
  - Add Alviro's public key.

Cc: Hazmi Alfarizqi <[email protected]> # @hzmi35
Cc: Alviro Iskandar Setiawan <[email protected]>
Signed-off-by: Ammar Faizi <[email protected]>
---
Ammar Faizi (1):
  Apply default SSH config and add public keys

 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

-- 
Ammar Faizi


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH server-a001 v2 1/1] Apply default SSH config and add public keys
  2022-04-15 17:49 [PATCH server-a001 v2 0/1] Apply default SSH config and add public keys Ammar Faizi
@ 2022-04-15 17:49 ` Ammar Faizi
  2022-04-15 17:55 ` [PATCH server-a001 v2 0/1] " Alviro Iskandar Setiawan
  1 sibling, 0 replies; 3+ messages in thread
From: Ammar Faizi @ 2022-04-15 17:49 UTC (permalink / raw)
  To: GNU/Weeb Mailing List
  Cc: Ammar Faizi, Hazmi Alfarizqi, Alviro Iskandar Setiawan

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 <[email protected]>
---
 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 [email protected]
+ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKhFfg8XTsIp3KM93LeLxOPtR/fGozCgtND9ySLbMUSA [email protected]
+ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJrp2IqgUsn1nwMMSS5QA56pFGb8RObcbgQVUiqBvg4V [email protected]
-- 
Ammar Faizi


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH server-a001 v2 0/1] Apply default SSH config and add public keys
  2022-04-15 17:49 [PATCH server-a001 v2 0/1] Apply default SSH config and add public keys Ammar Faizi
  2022-04-15 17:49 ` [PATCH server-a001 v2 1/1] " Ammar Faizi
@ 2022-04-15 17:55 ` Alviro Iskandar Setiawan
  1 sibling, 0 replies; 3+ messages in thread
From: Alviro Iskandar Setiawan @ 2022-04-15 17:55 UTC (permalink / raw)
  To: Ammar Faizi
  Cc: GNU/Weeb Mailing List, Hazmi Alfarizqi, Alviro Iskandar Setiawan

On Sat, Apr 16, 2022 at 12:49 AM Ammar Faizi <[email protected]> wrote:
>
> Hi,
>
> This is v2. Just a single patch here. This does 2 dependent things:
>
> 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.
>
> Please review!

Reviewed-by: Alviro Iskandar Setiawan <[email protected]>

tq

-- Viro

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-04-15 17:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-15 17:49 [PATCH server-a001 v2 0/1] Apply default SSH config and add public keys Ammar Faizi
2022-04-15 17:49 ` [PATCH server-a001 v2 1/1] " Ammar Faizi
2022-04-15 17:55 ` [PATCH server-a001 v2 0/1] " Alviro Iskandar Setiawan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox