What are the general things/setup that you do after getting a VPS/Dedicated server?
The obvious one is to change the SSH port.
Would be interesting to hear what are the other things that you do?
My Personal Blog | Currently Building LoadMyCode
The obvious one is to change the SSH port.
Would be interesting to hear what are the other things that you do?
My Personal Blog | Currently Building LoadMyCode
Comments
I never change SSH port, but I disable password authentication. Virmach support complains about this every time.
If the server is for idling, the best command to ensure security is:
We accept Karma donations for the last flan. 🍮 affbrr
Apply all updates (yum update, apt-get update, etc).
Enable SSH based key auth. Disable root logins. Consider hardening SSH via the Mozilla recommendations (https://infosec.mozilla.org/guidelines/openssh.html) turning off old insecure ciphers and such. As a warning this can cause some trouble if you have systems that don't support secure ciphers (ie, centos 6 sshing to centos 7). Consider changing the SSH port, but understand it is primarily to reduce log noise not really adding security.
Remove any unneeded services.
Enable syslog to publish logs remotely to either another server you own, or a free syslog aggrogator service. This way if you get compromised the compromisor can't delete logs.
Install monit if you have nothing better.
Firewall off all ports you aren't using.
Enable automatic installation of security patches.
Ionswitch.com | High Performance VPS in Seattle and Dallas since 2018
Install control panel
RackNode.net - High-Performance VDS & Dedicated Servers
|Paypal, Card and Crypto Payments Accepted|
Install CSF/LFD and change SSH port, that's about it.
I have a super scrappy script that I use to bootstrap Debian-based servers. Definitely a personal script, but it might help you out?
It don’t be like it is until it do.
This is amazing!! Exactly what everyone should be doing.
I hereby save it as ouvoun.sh
I might remove the docker part as I don't use docker for most of my projects.
Though would be interested to know how we could automate ssh keys here
Also, another important thing might be to configure/automate to somehow increase the ulimit. The default ulimits are always too small and often either slow down or crash most server software.
My Personal Blog | Currently Building LoadMyCode
Basically as per @ouvoun except
Python3 not 2
I'd actually run the apt upgrade. Not sure why it's commented out
The firewall config section is broken. It's setting up the rules but never actually enabling the firewall. Add a ufw enable
And you'll also need a ufw allow 22 else it'll cut off your ssh session the second you enable it given that rule provides for custom port only.
Totally fair. Once I discovered Docker I was addicted to being able to set up my existing stack within a couple of minutes. I’d never go back now.
Yeah I’d like that too. Frankly I’m too lazy to use ssh keys, but I know I should.
It don’t be like it is until it do.
Yeah, good catch on the firewall. I usually add a few more rules afterwards and then enable. I’ll edit the OP, thanks for the feedback!
It don’t be like it is until it do.
Knowing how there’s so many idling VPs y’all keep, I would just whitelist 2/3 vms IP and lock down access to my servers
Nexus Bytes Ryzen Powered NVMe VPS | NYC|Miami|LA|London|Netherlands| Singapore|Tokyo
Storage VPS | LiteSpeed Powered Web Hosting + SSH access | Switcher Special |
Hey I’ve only got two idlers, and that’s one more than I usually have.
It don’t be like it is until it do.
Anybody doing anything fancy with specific IPs? I've been toying with the idea of doing a dynamic dns type thing which tweaks firewall rules on the fly
Or alternatively blocking all countries except mine. I know iptables can do this via bulk rule import but havennt seen a clean way
I get what you're saying but don't agree 100%. Cutting down bot attempts from 100s to near zero has to have some security benefit
This is classically known as security through obscurity. Changing the SSH port is obscuring it. If your SSHd/settings/users are secure, port 22 or 222 becomes simply a logging exercise. If your SSHd/settings/users are not secure, it becomes a hope that no one is scanning obscure ports, doing banner detection, and then brute forcing.
At the end of the day, SSH really shouldn't be exposed on a server to the public internet. In Amazon land (AWS) we Systems Manager that allows out-of-band access to VM's without SSH. In private datacenters you need (generally) a VPN. The majority of providers (myself included) do not offer an easy way to not expose SSH, but allow easy access when you need it.
To really go deeper, we would need a beer... It's a debatable gray area.
Then I saw this -- which is exactly what I was suggesting.
Where
allowandremoveaccess would hit the providers API to open a network firewall to your instance.Ionswitch.com | High Performance VPS in Seattle and Dallas since 2018
This is neat, though I wouldn't be able to do this with multiple providers and I am not sure if all providers have such APIs.
Personally, I would probably use some kind of VPN server, but then again you would need another fallback VPN server if you loose access to the primary VPN server, you might end up locking yourself out.
My Personal Blog | Currently Building LoadMyCode
Unfortunately you are right... A next-best-thing is likely whitelisting a host or two as a jump-box that you keep updated and secured.
Ionswitch.com | High Performance VPS in Seattle and Dallas since 2018
• If a program actually fits in memory and has enough disk space, it is guaranteed to crash.
• If such a program has not crashed yet, it is waiting for a critical moment before it crashes.
No its not.
Youre not relying on obscurity for safety. You're running the exact same security as normal. But moving it to a non 22 port.
Its a additional step on top of normal security measures that happens to cut login attempts dramatically. That's not security through obscurity. It's a big win basically for free
Given a choice do you want to be on a port that:
A) gets hammered 247 with login attempts
B.)does not
Forget the high level arguments. That's just common sense
Really, it is not necessary and won't give any extra to security the change of the ssh port. If you are so paranoid, this is a good article (even if it's old) and suggests another approach to keep attackers blind as of port 22: https://www.adayinthelifeof.nl/2012/03/12/why-putting-ssh-on-another-port-than-22-is-bad-idea/
• If a program actually fits in memory and has enough disk space, it is guaranteed to crash.
• If such a program has not crashed yet, it is waiting for a critical moment before it crashes.
It's a pretty simple argument, what security does moving the port provide other than obscurity? None. Therefore the only thing it provides is security through obscurity.
My opinion on this:
1) All of the tools I use on my boxes support ports other than the default
2) It’s super easy to change
3) A non-default port won’t get slapped as hard
So for me, it’s a no brainer. Might not be that more secure, but I don’t see why it hurts at all.
Of course I understand there are setups where a non-default SSH port complicates things. That’s not the case for me and (I assume) quite a few others on this forum.
It don’t be like it is until it do.
Here is an updated version of the script from @ouvoun and some enhancements(untested) by @HostDoc to support/deploy SSH keys and hostname.
Don't forget to replace the XX
My Personal Blog | Currently Building LoadMyCode
Well, for me, it looks like, that script installs bloat, which makes the vps more insecure, instead of what it should do when you run it first, is making the vps more secure.
You may also try:
Free NAT KVM | Free NAT LXC
The original poster asked for opinions on what people do on a new server. I assume by “bloat” you mean Docker. And that’s fair. But I depend on Docker; that’s why it’s included.
Of course if you want a secure box, disable login and shut it down forever.
It don’t be like it is until it do.
I like to think NOT getting hit with brute-force attempts lightens the load on the server, by not having to deal with that pesky aspect.
Hey teamacc. You're a dick. (c) Jon Biloh, 2020.
Heh heh heh ... that I won't argue with but that's not really a security gain unless you're arguing it makes auditing the logs easier. I prefer iptables rate-limiting for that.
I am low key afraid of limiting access of SSH for certain IP only because I keep thinking what if suddenly all my whitelisted IP are no longer usable? Given that no VNC, KVM or IPMI is available, that will cause more trouble and it compromised availability.
食之无味 弃之可惜 - Too arduous to relish, too wasteful to discard.
Change ssh port and set up IP allow SSH tcp wrapper on /etc/hosts.allow then /etc/hosts.deny for ssh deny all
Change SSH port, add new sudo user, disallow root, let idle till expired.
I do this too.
On top of that, iptables ACCEPT/DROP
"The imitator dooms himself to hopeless mediocrity." — Ralph Waldo Emerson
I do not need statefull connection tracking firewall (performance reasons)
If you use iptbales, just add a custom iptables rule in RAW table and mark everything as non tracking.
Install zerotier, add new vps to my zerotier network, close all firewall ports except from zerotier.
DM us for private tracker invite.
I do something similar to @ouvoun's script, except via Ansible. Just have to manually configure SSH keys and install Python3 and then Ansible handles the rest. The Debian installer already asks to create a new user, so I guess that part of your script wouldn't be necessary if you install from ISO.
Maybe I should post my Ansible playbooks somewhere.
Daniel15 | https://d.sb/. List of all my VPSes: https://d.sb/servers
dnstools.ws - DNS lookups, pings, and traceroutes from 30 locations worldwide.
My 2 cents: If you secure your server correctly, you won't have to be afraid for those brute-force attempts. By changing the port you're merely obscuring that there is an SSH daemon running on your box. So it really is security by obscurity.
I don't change the default SSH-port because I work behind firewalls dat won't let me make an SSH-connection to a non-privileged port. I also think this is generally not a good idea.
I disable ssh root login after employing a new VM or dedi, adding a user with sudo-rights and only allowing access with keys. I setup Fail2Ban and iptables rate-limiting. Just to be sure I limit access to port 22 from a number of subnets that are well known for brute-forcing SSH (Online.net, China Telecom). That last part is security by obscurity as well of course...
On some boxes I don't want this hassle and I just limit access to SSH from my home ip-address, my work ip-address, the CGNAT subnets from my mobile provider and my other boxes.
No server I managed has ever been compromised, nor am I experiencing high load from those SSH bruteforcers.
I am curious, is this different from an OpenVPN jump box setup?
My Personal Blog | Currently Building LoadMyCode
They might be similar. But zerotier is way easier to configure than openvpn though.
DM us for private tracker invite.
That's why IMO is crucial to have a sudo user with complex username/pasword combilation that can be used in those cases.
• If a program actually fits in memory and has enough disk space, it is guaranteed to crash.
• If such a program has not crashed yet, it is waiting for a critical moment before it crashes.
I usually perform a set of action required to score 80+ on lynis. While the score, per se, is mostly pointless, some of the suggestions aren't pointless to me. These involve:
And more:
I dare to harden OpenSSH too. Changing port is convenient even if it doesn't harden, a flooded log is a potentially unhelpful log (even more w/o fail2ban). I have no mandatory requirements about picking port 22 and leaving it wide open. I pick another privileged port and on top of it I restrict it to a handful of static IPs (Wireguard VPNs + office), I have no reasons to leave it open to the wide internet. If all my VPNs and my workplace gets nuked from orbit (or, more likely, if there's some exceedingly unexpected OpenSSH configuration error) there's an emergency rate-limited and filtered dropbear instance listening on an IPv6-only privileged port. Range scans are invariably caught with an ip{,6}tables "recent" module, the most obnoxious and notorious offenders are dealt with ipsets, using (highly conservative) blocklists too.
Then, I power it off.
I normally do this as well:
Deals and Reviews: LowEndBoxes Review | Avoid dodgy providers with The LEBRE Whitelist | Free hosting (with conditions): Evolution-Host, NanoKVM, FreeMach, ServedEZ | Get expert copyediting and copywriting help at The Write Flow
Well, you limit it, to multiple gateways, not just one.
Free NAT KVM | Free NAT LXC
I have no firewall, no SSH port change, no fail2ban. I just disabled password login. Why am I not hacked?
Or, am I already hacked but I don't know?
We accept Karma donations for the last flan. 🍮 affbrr
That script is just missing a few steps to cover all I need:
I may add some additional jails on fail2ban depending on what services are running on the server.
Bench script
Action and Reaction in history
Probably tie a yellow wrist ribbon somewhere?
DM us for private tracker invite.
You're fine mate, as long as you're only idling the ssh daemon on a public port, and no other.
Most of my boxen are double duty and rsync over default ssh port is too important to give up. I use 3 trylimit fail2ban and a multiday bantime in order to keep my logs legible.
I also have nginx on 80 and 443.
I moved Asterisk to 15060. Someone keeps trying different SIP passwords, wanting to make long distance calls. My passwords are randomly generated so they can't succeed, and I only have $1 long distance credit. I changed port because Asterisk log file fills the disk every 3 days and then the server crashes.
I have virtual machines (VirtualBox in university servers, not VPS) on alternate ports. I use
$HOME/.ssh/configto set the ports. rsync and everything else work fine.We accept Karma donations for the last flan. 🍮 affbrr
I see what you did there ...
HS4LIFE (+ (* 3 4) (* 5 6))
Zerotier is a mesh VPN, so it's more like a private P2P network. Traffic doesn't have to go through a central server. It's also a hosted service, so you don't have to keep your own box working.
Tinc and Wireguard are similar.
I keep meaning to get a wireguard network setup, and see if I can get rid of the IPSec/OpenVPN monstrosity at work.
Is this real German or fake German?
DM us for private tracker invite.
hörbar lachen
sicher, das ist kein Hochdeutsch!
HS4LIFE (+ (* 3 4) (* 5 6))