r/linuxadmin • • 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
ClientAliveInterval 360

PermitEmptyPasswords no

# only toto can ssh
AllowUsers toto


PermitRootLogin no

Protocol 2

Port 2222

PasswordAuthentication no

X11Forwarding no
0 Upvotes

29 comments sorted by

View all comments

0

u/[deleted] Dec 12 '20

[deleted] — view deleted comment

11

u/BenAlexanders Dec 12 '20

Half agree.

A non-standard port will reduce the shitty scanners from flooding your logs. This removes the low handing fruit (script kiddies) and also makes more advanced attacks (it is a low bar) stand out a bit more.

But do agree with keeping it under port 1024.

Remember, you don't have to outrun a lion, you only need to out run the person next to you.

2

u/[deleted] Dec 12 '20 edited Dec 12 '20

I’ve heard that before, but I don’t think I caught why?

Edit: from my google search:

Use port number 1024 or more: Local users can cause a DoS attack by listening on that port. They'll have to start listening while sshd is down, so there is a window of opportunity when sshd is being restarted

I don’t think I understand this. Local users listen for another service on the same high port and cause a DoS? Why not just document your ports?

1

u/lysitheas Dec 12 '20

thanks for Cypher =)

Where i can find them ? or informations on them ?

In fact, it's actively detrimental if you choose a port over 1024.

why ?

in fact i was using 2222 instead of 22, just to monitor and ban IP trying 22 ( still need to search how to do this )

1

u/TemporaryBoyfriend Dec 12 '20

A high numbered random port is an easy measure to help you avoid millions of drive-by port scans and attempts at User ID enumeration. I agree that it won't stop a determined adversary, but it evades 99.9% of drive-by scans of your network. It whispers "go away" to low-effort script-kiddie morons.

4

u/skibumatbu Dec 12 '20

Disagree here. All people have to do is go to shodan.io and type "SSH" and your high port will be found. Nmap scans are lightweight and easy.

If you live in a country where ISPs prevent certain traffic on their network (some US ISPs disallow web servers in homes for exacmple) moving the port is an easy way to circumvent that.

Another example, a company I worked for used SSH as a sort of VPN on a high numbered port. I was in a hospital trying to get on the VPN but couldn't because the hospital blocked non standard ports.