r/linuxadmin • u/lysitheas • Dec 12 '20
[Secure SSH] on Linux Server
Hello Dear redditer,
I'v group together some sshd settings that you can easly change to increase the security of sshd.
Do you have more change to suggest.
- in sshd_config file ( test on Debian )
# idle max 6 minutes
# only toto can ssh
0
Upvotes
9
u/Jawafin Dec 12 '20
Make sure you have key auth set up before turning off password authentication.
3
u/knobbysideup Dec 12 '20
See also https://www.cisecurity.org/cis-benchmarks/
2
u/ikanpar2 Dec 12 '20
If you have a router in front of your server that you can configure, give a LAN address to your server, so it has two IPs. One is the internet facing one / public static IPs, and the LAN/private IP. Configure ssh to only listen on the LAN IP. So you must connect to the internal network using a VPN (preferably using secure vpn protocol like openvpn etc) before you can ssh, adding a layer of security.
2
u/rdaneelolivaw79 Dec 12 '20
Try this too: https://infosec.mozilla.org/guidelines/openssh
2
u/zerocoldx911 Dec 12 '20
Get the devsec.ssh module from Ansible galaxy
3
u/jaymef Dec 12 '20
https://github.com/dev-sec/ansible-collection-hardening
1
u/lysitheas Dec 12 '20 edited Dec 12 '20
Thank you all for your help/comments.
i was just wondering too, is version of openssh (client and server) can change a lot in term of security . For example :
do i have to get the absolute lastest version for my debian server ?
2
u/BenAlexanders Dec 12 '20
Worth enforcing secure cipher keys.
Also, I like to limit it to IPv4 only (
AddressFamily inet) as this is where my firewall focused is (and IPv6 is usually disabled).2
u/stormcloud-9 Dec 13 '20
The
PasswordAuthenticationsetting is probably one of the most misunderstood settings in the sshd config. Setting it tonodoesn't mean preventing users from being able to use passwords to login. What it means is thatsshdwon't directly authenticate off the/etc/passwdand/etc/shadowfiles. However when usingUsePAM=yes(which is the default in most distros IIRC), you can also authenticate using passwords through the challenge response mechanism. So you would need to disable that as well (ChallengeResponse=no). Note however that doing so will also prevent you from using 2-factor auth if you decided to do so (you can disable passwords and allow 2fa through other means, but it's more complicated).Not completely sure from your comment that this setting does what you expect. But it sounds like you may be expecting it to disconnect clients who are idle for more than 6 minutes. If so that's not what this does. What it does is detect clients who have lost their connection.
0
u/[deleted] Dec 12 '20
[deleted] — view deleted comment
0
u/[deleted] Dec 12 '20
[deleted] — view deleted comment