AnonymousLemming ,

Use a hardened-by-default OS like OpenBSD, HardenedBSD, or something similar in Linux.

Reaper948 ,

Air gapping

/s

lemmyreader ,

Ask yourself a few questions first before following the massive amount of suggestions and then locking yourself out and so on.

  • What are you worried about ?
  • How important is your stuff ?
  • Make backups and check them

Still worried ? Then there's the easy way out : Hire some security auditor to help you find holes you left.

TheDarkBanana87 ,

Stumbled uppon this guide

https://github.com/imthenachoman/How-To-Secure-A-Linux-Server

I think its a good place to start

LordOfTheChia ,

Do a search for you server OS + STIG

Then, for each service you're hosting on that server, do a search for:

Service/Program name + STIG/Benchmark

There's tons of work already done by the vendors in conjunction with the DoD (and CIS) to create lists of potential vulnerable settings that can be corrected before deploying the server.

Along with this, you can usually find scripts and/or Ansible playbooks that will do most of the hardening for you. Though it's a good Idea to understand what you do and do not need done.

Lemongrab ,
___ ,

Run SCAP tool with a STIG baseline.

possiblylinux127 ,
@possiblylinux127@lemmy.zip avatar

Check out online resources such as the Nist cyber stuff.

Basic things include disabling unnecessary services, disabling password authentication, setting up and verifying the firewall, configuring selinux and so on.

Harbinger01173430 ,

Don't turn it on is the ultimate technique

ChaoticNeutralCzech ,

That's why "availability" is a core tenet of security (according to some cybersecurity course I took). It is easy to prevent unauthorized access to data if you have no requirements on authorized access.

A_Random_Idiot ,
@A_Random_Idiot@lemmy.world avatar

barring that, unplug the ethernet.

rimu ,
@rimu@piefed.social avatar

Ubuntu has a set of scripts you can run to harden a new server (not advisable on a server that has already been configured for something). You need an Ubuntu Pro subscription to access them but you can get a free trial and then cancel it after you've finished.

More info at https://ubuntu.com/security/cis.

I did this process for a customer recently and it was pretty straightforward and much much more thorough (over 100 configuration changes) than just tweaking SSH and fail2ban.

I expect other commercially-oriented distros offer something similar.

tills13 ,

Leak the scripts?

MindlessZ ,

Fwiw you don't need to cancel or trial anything. Everyone can get free Ubuntu pro licensesbfor up to 5 machines

dallen ,

I like to require access to 22 via IP whitelist and all services on SSL behind a reverse proxy. Doesn’t leave much surface to attack.

phoenixz ,

Also, move ssh to a different, higher port. Since ssh isn't exactly for noobs, changing the port is easy enough to work with and that alone already reduces port scans and what not

nik282000 ,
@nik282000@lemmy.ca avatar

I recently setup Guacamole (Web based VNC/RDP/SSH) with totp and was able to close external SSH access. Now everything I run can sit behind a single reverse proxy, no extra ports.

h3ndrik , (edited )
  • fail2ban / brute forcing prevention
  • quick, frequent updates(!)
  • containerization / virtualization
  • secure passwords, better keys
  • firewall
  • a hardened operating system (distribution)
  • SELinux / Apparmor / ... / OpenBSD
  • not installing unnecessary stuff
  • An admin who is an expert and knows what they do.
wreckedcarzz ,
@wreckedcarzz@lemmy.world avatar

Me, two+ decades into tinkering and still a dumbass: "look at me, I'm the expert admin now"

SirMaple_ ,
@SirMaple_@lemmy.sirmaple.ca avatar
  • crowdsec
  • SSH - change port, disable root login, disable password login, setup SSH keys using SK(YubiKey in my case)
  • nftables - I use https://github.com/etkaar/nftm to keep things quick and simple. I like the fact if will convert DNS entries to IPs. I then just use dynamic DNS update clients on all my endpoints
  • WireGuard for access to services other than SSH(in some cases port 443 will be open if its a web server or proxy)
  • rsyslog to forward auth logs to my central syslog server
ShortN0te ,

disable root login

That does not do much in practice. When a user is compromised a simple alias put in the .bashrc can compromise the sudo password.

Explicitly limit the user accounts that can login so that accidentally no test or service account with temporary credentials can login via ssh is the better recommendation.

drkt ,
@drkt@lemmy.dbzer0.com avatar

I think the point is that root is a universal user found on all linux systems where as users have all kinds of names. It narrows down the variables to brute-force, so simply removing the ability to use it means they have to guess a username and a password.

ShortN0te ,

guess a username and a password.

Security by obscurity is no security. Use something like fail2ban to prevent brute force.
When you use a secure password and or key this also does not matter much.

wreckedcarzz ,
@wreckedcarzz@lemmy.world avatar

Something something don't let 'good' be the enemy of 'perfect'

slazer2au ,

Move services away from known ports and don't use ports that end with well known port numbers (22,80,443).

Moving ssh from 22 to 2222 or 443 to 10443 does nothing. You have ~65000 ports. Pick something random like 6744 or 2458

towerful ,

Changing ports does nothing except reduced log chatter.
Security through obscurity is not security

slazer2au ,

Moving ports does help. It is not a sure thing but when used in conjunction with other security mechanism can help get rid the of the low hanging fruit of scriptkiddies and automated scans.

towerful ,

But scriptkiddies and automated scans are not a security threat. If they were a legitimate threat to your server, you have bigger problems.
All it does is reduce log chatter.

Anyone actually wanting in would port scan, then try and connect to each port, and quickly identify an SSH port

solrize ,

Imagine that the xz exploit actually made it into your server, so your sshd was vulnerable. Having it on another port does seem helpful then. In fact i sometimes think of putting mine on a random secret address in the middle of a /64 ipv6 range, but I haven't done that yet.

it occurs to me, the xz exploit and similar is a good reason not to run the latest software. It affected Debian Sid but not the stable releases. I'm glad I only run the stable ones.

ShortN0te ,

Imagine that the xz exploit actually made it into your server, so your sshd was vulnerable. Having it on another port does seem helpful then.

Nope. Your entire server can be scanned in less than a second for an open ssh port.

IPv6 does not change the fact since when your server is attacked the hist IP is already known.

solrize ,

Maybe I'm missing something but how is the host ip known? The server has a maybe-known range of addresses, but I don't announce which address has an sshd listening. There are 2**64 addresses in the range, so scanning in 1 second doesn't sound feasible.

possiblylinux127 ,
@possiblylinux127@lemmy.zip avatar

I've never seen an attack that scans all ports. Normally it just checks open ports and then tries common credentials and exploits. If that fails it moves on to the next IP.

Changing the default port on SSH probably isn't going to do much as SSH is already pretty secure. However it is a good rule of thumb to change the defaults.

possiblylinux127 ,
@possiblylinux127@lemmy.zip avatar

The XZ backdoor was not exploited so it is hard to say what would of been effective.

The important thing to note is changing the defaults on systems. Defaults are bad because it makes it easy to take over a large number of systems easily. Even right now there are bots testing common ports for weaknesses.

towerful ,

Just have 2 ipv4 assigned to your server. Have 1 for all your services, and run ssh on the other allowing root login with the password "admin".
A random ipv6 in the same subnet as your server is just obscurity.

The XZ exploit would be functionally similar to allowing root login using the password "admin".
Would doing that on a different port be secure? No? Then a different port is not security, it's obscurity.

Obscurity is just going to trip you up at some point and reduce log chatter.

And yes, running LTSB/stable is a sensible choice for servers.

possiblylinux127 ,
@possiblylinux127@lemmy.zip avatar

Automated attacks are a huge threat. Changing defaults shouldn't be your only security practice but it can significantly help defend a network.

ShortN0te ,

Security by obscurity is no security.

possiblylinux127 ,
@possiblylinux127@lemmy.zip avatar

It is if you are defending against automation.

towerful ,

It defends against the lowest level of automation. And if that is a legit threat in your model, you are going to have a bad time.
It's just going to trip you up at some point

possiblylinux127 ,
@possiblylinux127@lemmy.zip avatar

I'm not saying it should be your only defense. I'm saying that changing defaults is a good idea for secure systems.

For instance, you should change the default WiFi password on your router.

towerful ,

Yes, because a password is security

possiblylinux127 ,
@possiblylinux127@lemmy.zip avatar

So is changing the port. It won't do a lot in terms of security but it will help a tiny bit

possiblylinux127 ,
@possiblylinux127@lemmy.zip avatar

It breaks automation. Same thing for changing any default. Change default names, directories and anything else that's to predictable

tgxn ,
@tgxn@lemmy.tgxn.net avatar

Still does nothing when scanning the entire ipv4 address space achievable so quickly. You can also use services like shodan to find vulnerable services on any ports.

Use SSH keys, stay upgraded. Make management services (SSH, RDP, admin services) accessible only via VPN (WireGuard). Only expose 80 and 443 to the internet, if necessary.

JustEnoughDucks ,
@JustEnoughDucks@feddit.nl avatar

Just don't port forward ssh. There is 0 reason to in 99.99% of home cases

Decronym Bot , (edited )

Acronyms, initialisms, abbreviations, contractions, and other phrases which expand to something larger, that I've seen in this thread:

Fewer Letters More Letters
DNS Domain Name Service/System
IP Internet Protocol
SSH Secure Shell for remote terminal access
SSL Secure Sockets Layer, for transparent encryption
TCP Transmission Control Protocol, most often over IP
VNC Virtual Network Computing for remote desktop access
VPN Virtual Private Network
VPS Virtual Private Server (opposed to shared hosting)

[Thread for this sub, first seen 20th Apr 2024, 15:55]
[FAQ] [Full list] [Contact] [Source code]

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • selfhosted@lemmy.world
  • test
  • worldmews
  • mews
  • All magazines