* [PATCH server-a001 v1 0/1] Apply default SSH config and add public keys @ 2022-04-15 17:15 Ammar Faizi 2022-04-15 17:15 ` [PATCH server-a001 v1 1/1] " Ammar Faizi 0 siblings, 1 reply; 6+ messages in thread From: Ammar Faizi @ 2022-04-15 17:15 UTC (permalink / raw) To: GNU/Weeb Mailing List Cc: Ammar Faizi, Hazmi Alfarizqi, Alviro Iskandar Setiawan Hi, Just a single patch here. 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! 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 | 2 + 3 files changed, 138 insertions(+), 3 deletions(-) create mode 100644 etc/ssh/sshd_config create mode 100644 ssh_keys/authorized_keys -- Ammar Faizi ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH server-a001 v1 1/1] Apply default SSH config and add public keys 2022-04-15 17:15 [PATCH server-a001 v1 0/1] Apply default SSH config and add public keys Ammar Faizi @ 2022-04-15 17:15 ` Ammar Faizi 2022-04-15 17:29 ` Alviro Iskandar Setiawan 2022-04-15 17:33 ` Alviro Iskandar Setiawan 0 siblings, 2 replies; 6+ messages in thread From: Ammar Faizi @ 2022-04-15 17:15 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 | 2 + 3 files changed, 138 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..4cbe84f --- /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 yes +#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..6465aa5 --- /dev/null +++ b/ssh_keys/authorized_keys @@ -0,0 +1,2 @@ +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIK4MbVLR2847dHKdtr4M0p9g3M1Q9eiv4Lhr1x1x6RJ1 [email protected] +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKhFfg8XTsIp3KM93LeLxOPtR/fGozCgtND9ySLbMUSA [email protected] -- Ammar Faizi ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH server-a001 v1 1/1] Apply default SSH config and add public keys 2022-04-15 17:15 ` [PATCH server-a001 v1 1/1] " Ammar Faizi @ 2022-04-15 17:29 ` Alviro Iskandar Setiawan 2022-04-15 17:36 ` Ammar Faizi 2022-04-15 17:33 ` Alviro Iskandar Setiawan 1 sibling, 1 reply; 6+ messages in thread From: Alviro Iskandar Setiawan @ 2022-04-15 17:29 UTC (permalink / raw) To: Ammar Faizi Cc: GNU/Weeb Mailing List, Hazmi Alfarizqi, Alviro Iskandar Setiawan On Sat, Apr 16, 2022 at 12:16 AM Ammar Faizi <[email protected]> wrote: > > 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. The sshd_config in this patch doesn't disable the password auth, tho This: > +PermitRootLogin prohibit-password only disables password auth for root, you're still asked to enter the password, but it will never work for root even if the root password is correct. However, if the login user is not root, the password auth is still valid. > +# To disable tunneled clear text passwords, change to no here! > +#PasswordAuthentication yes This should be set to "no" to really disable password auth. -- Viro ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH server-a001 v1 1/1] Apply default SSH config and add public keys 2022-04-15 17:29 ` Alviro Iskandar Setiawan @ 2022-04-15 17:36 ` Ammar Faizi 0 siblings, 0 replies; 6+ messages in thread From: Ammar Faizi @ 2022-04-15 17:36 UTC (permalink / raw) To: Alviro Iskandar Setiawan Cc: GNU/Weeb Mailing List, Hazmi Alfarizqi, Alviro Iskandar Setiawan On 4/16/22 12:29 AM, Alviro Iskandar Setiawan wrote: > On Sat, Apr 16, 2022 at 12:16 AM Ammar Faizi <[email protected]> wrote: >> >> 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. > > The sshd_config in this patch doesn't disable the password auth, tho > > This: > >> +PermitRootLogin prohibit-password > > only disables password auth for root, you're still asked to enter the > password, but it will never work for root even if the root password is > correct. However, if the login user is not root, the password auth is > still valid. > >> +# To disable tunneled clear text passwords, change to no here! >> +#PasswordAuthentication yes > > This should be set to "no" to really disable password auth. Ack, yes, my bad. Will fix it in the v2. -- Ammar Faizi ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH server-a001 v1 1/1] Apply default SSH config and add public keys 2022-04-15 17:15 ` [PATCH server-a001 v1 1/1] " Ammar Faizi 2022-04-15 17:29 ` Alviro Iskandar Setiawan @ 2022-04-15 17:33 ` Alviro Iskandar Setiawan 2022-04-15 17:37 ` Ammar Faizi 1 sibling, 1 reply; 6+ messages in thread From: Alviro Iskandar Setiawan @ 2022-04-15 17:33 UTC (permalink / raw) To: Ammar Faizi Cc: GNU/Weeb Mailing List, Hazmi Alfarizqi, Alviro Iskandar Setiawan On Sat, Apr 16, 2022 at 12:16 AM Ammar Faizi <[email protected]> wrote: > +++ b/ssh_keys/authorized_keys > @@ -0,0 +1,2 @@ > +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIK4MbVLR2847dHKdtr4M0p9g3M1Q9eiv4Lhr1x1x6RJ1 [email protected] > +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKhFfg8XTsIp3KM93LeLxOPtR/fGozCgtND9ySLbMUSA [email protected] Can you add my public key too sir? ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJrp2IqgUsn1nwMMSS5QA56pFGb8RObcbgQVUiqBvg4V [email protected] -- Viro ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH server-a001 v1 1/1] Apply default SSH config and add public keys 2022-04-15 17:33 ` Alviro Iskandar Setiawan @ 2022-04-15 17:37 ` Ammar Faizi 0 siblings, 0 replies; 6+ messages in thread From: Ammar Faizi @ 2022-04-15 17:37 UTC (permalink / raw) To: Alviro Iskandar Setiawan; +Cc: GNU/Weeb Mailing List, Hazmi Alfarizqi On 4/16/22 12:33 AM, Alviro Iskandar Setiawan wrote: > On Sat, Apr 16, 2022 at 12:16 AM Ammar Faizi <[email protected]> wrote: >> +++ b/ssh_keys/authorized_keys >> @@ -0,0 +1,2 @@ >> +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIK4MbVLR2847dHKdtr4M0p9g3M1Q9eiv4Lhr1x1x6RJ1 [email protected] >> +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKhFfg8XTsIp3KM93LeLxOPtR/fGozCgtND9ySLbMUSA [email protected] > > Can you add my public key too sir? > > ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJrp2IqgUsn1nwMMSS5QA56pFGb8RObcbgQVUiqBvg4V > [email protected] Yes, I will add your public key in the v2. -- Ammar Faizi ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-04-15 17:37 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-04-15 17:15 [PATCH server-a001 v1 0/1] Apply default SSH config and add public keys Ammar Faizi 2022-04-15 17:15 ` [PATCH server-a001 v1 1/1] " Ammar Faizi 2022-04-15 17:29 ` Alviro Iskandar Setiawan 2022-04-15 17:36 ` Ammar Faizi 2022-04-15 17:33 ` Alviro Iskandar Setiawan 2022-04-15 17:37 ` Ammar Faizi
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox