TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

My First 10 Minutes on a Server

1282 pointsby codelittalmost 9 years ago

58 comments

brokenwrenalmost 9 years ago
This one is pretty decent but if you want the ultimate guide check out this one:<p><a href="https:&#x2F;&#x2F;www.inversoft.com&#x2F;guides&#x2F;2016-guide-to-user-data-security" rel="nofollow">https:&#x2F;&#x2F;www.inversoft.com&#x2F;guides&#x2F;2016-guide-to-user-data-sec...</a><p>It covers 10x what all the other guides cover in terms of server and application security. It was posted a few weeks ago on HN but didn&#x27;t make the front-page.
评论 #11909873 未加载
评论 #11910033 未加载
评论 #11911175 未加载
评论 #11911018 未加载
评论 #11910334 未加载
评论 #11909885 未加载
评论 #11910762 未加载
评论 #11914257 未加载
jlduggeralmost 9 years ago
&gt; We don&#x27;t even have a password for our root user. We&#x27;ll want to select something random and complex.<p>So you&#x27;re taking something secure by default -- no password means no login allowed, and making it less secure. And if you have hundreds of these servers, you&#x27;ll need to rotate them whenever someone on the team leaves. This is painful.<p>Simple solution: leave root password blank, don&#x27;t forget your sudo password. If you can&#x27;t get in, use grub or a liveCD. Or tie auth to ldap or kerberos so you _can&#x27;t_ forget. This is one area where Windows has a distinct advantage: AD more or less requires admins to think at the level of network of servers, and provides a baseline set of services always present.
评论 #11910407 未加载
评论 #11911591 未加载
评论 #11913430 未加载
评论 #11909960 未加载
评论 #11912542 未加载
评论 #11910204 未加载
malingoalmost 9 years ago
This is good advice on achieving the most secure SSH configuration: <a href="https:&#x2F;&#x2F;stribika.github.io&#x2F;2015&#x2F;01&#x2F;04&#x2F;secure-secure-shell.html" rel="nofollow">https:&#x2F;&#x2F;stribika.github.io&#x2F;2015&#x2F;01&#x2F;04&#x2F;secure-secure-shell.ht...</a><p>&quot;My goal with this post here is to make NSA analysts sad.&quot;
评论 #11910765 未加载
评论 #11909869 未加载
tjohnsalmost 9 years ago
&gt; I check our logwatch email every morning and thoroughly enjoy watching several hundreds (sometimes 1000s) of attempts at gaining access with little prevail.<p>This is something that actually bugs me a bit. These attacks are so common, getting emails like this every day contributes to alarm fatigue. (<a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Alarm_fatigue" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Alarm_fatigue</a>)<p>I&#x27;d love to see the Linux nightly security scripts replaced with something that only sends out emails when there&#x27;s an specific <i>actionable</i> event I need to pay attention to. Ideally in a way that can easily be aggregated over all the machines I manage.
评论 #11911179 未加载
评论 #11916833 未加载
评论 #11911069 未加载
chrisfosterellialmost 9 years ago
&gt; sudo ufw allow from {your-ip} to any port 22<p>I&#x27;m surprised nobody mentioned this is a great way to shoot yourself in the foot if you don&#x27;t have a static IP.
评论 #11910475 未加载
ryanmarshalmost 9 years ago
I don&#x27;t mean to sound flippant but why can&#x27;t these &quot;lock down your new box&quot; tutorials just be a bash script? Shouldn&#x27;t they be?
评论 #11910430 未加载
评论 #11910240 未加载
评论 #11910259 未加载
评论 #11910310 未加载
评论 #11910302 未加载
评论 #11910315 未加载
评论 #11911723 未加载
评论 #11910279 未加载
评论 #11910342 未加载
评论 #11910203 未加载
评论 #11910271 未加载
评论 #11910216 未加载
评论 #11910206 未加载
评论 #11910253 未加载
Someone1234almost 9 years ago
Why do people install fail2ban then disable password based authentication entirely? I legitimately don&#x27;t understand the purpose.<p>Also, they complain about log spam (from failed SSH attempts) this is one reason to move SSH to a different port. It does NOT increase security, but it DOES reduce log spam from bots trying for easy targets.
评论 #11910268 未加载
评论 #11910601 未加载
评论 #11912393 未加载
评论 #11912839 未加载
nblralmost 9 years ago
Fail2ban? sshguard? unnecessary. Just disable ssh passwd auth (which generally is a good idea) -&gt; done&#x2F;done<p>If you don&#x27;t like lognoise from ssh scanners (even if you disable passwd auth), move your sshd port to some random high port and make note of it in your ~&#x2F;.ssh&#x2F;config<p>Generally: if in doubt, take the more simple and elegant solution to a problem.
评论 #11910262 未加载
评论 #11926055 未加载
teddyhalmost 9 years ago
I prefer the “Securing Debian Manual” – it’s an <i>official manual</i> from the Debian project.<p><a href="https:&#x2F;&#x2F;www.debian.org&#x2F;doc&#x2F;manuals&#x2F;securing-debian-howto&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.debian.org&#x2F;doc&#x2F;manuals&#x2F;securing-debian-howto&#x2F;</a>
raimuealmost 9 years ago
Be aware fail2ban does not handle IPv6 at all with its default configuration on Debian&#x2F;Ubuntu.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;fail2ban&#x2F;fail2ban&#x2F;issues&#x2F;1123" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;fail2ban&#x2F;fail2ban&#x2F;issues&#x2F;1123</a>
评论 #11915791 未加载
评论 #11910481 未加载
seagreenalmost 9 years ago
Great tactical advice, but what a sad situation to be in. &quot;Run this command, then run this command, then run this command ...&quot;<p>There should be a single configuration file (or set of files) that declaratively describes the whole state of the machine. That way the exact situation of the server can be reviewed by just looking at files, instead of trying to poke and prod at the machine to see what commands have been run over the last X weeks.
评论 #11910396 未加载
p8donaldalmost 9 years ago
Since I changed the default SSH port of 22 to something else (like 4422), I no longer get any of these drive-by attacks and don&#x27;t need fail2ban anymore.<p>I also like to set up a simple Monit configuration to alert me about high cpu usage or when the disk space is about to run out. Instead of emailing me these alerts (and also weekly reports) I&#x27;ve configured Monit to post them to my Slack team of 1.<p><a href="https:&#x2F;&#x2F;peteris.rocks&#x2F;blog&#x2F;monit-configuration-with-slack&#x2F;" rel="nofollow">https:&#x2F;&#x2F;peteris.rocks&#x2F;blog&#x2F;monit-configuration-with-slack&#x2F;</a>
评论 #11914941 未加载
adrianmsmithalmost 9 years ago
What&#x27;s the reason for using a firewall?<p>Assuming that services which shouldn&#x27;t be accessible to the outside only listen to localhost not the network (e.g. MySQL on a LAMP stack), isn&#x27;t that sufficient?<p>(Honest question, I don&#x27;t have much experience with syadmin.)
评论 #11910446 未加载
评论 #11910421 未加载
评论 #11910449 未加载
评论 #11911045 未加载
评论 #11911085 未加载
评论 #11913105 未加载
评论 #11910935 未加载
elbearalmost 9 years ago
Here&#x27;s an Ansible role (I made it) that automates the steps described in the article: <a href="https:&#x2F;&#x2F;github.com&#x2F;LucianU&#x2F;ansible-secure" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;LucianU&#x2F;ansible-secure</a>.
评论 #11919238 未加载
评论 #11913241 未加载
tobltobsalmost 9 years ago
Can somebody help me out with this question: The default config for unattended-upgrades seems to not enable reboot even if a reboot would be required to activate the upgrades. Wouldn&#x27;t that had made quite a few important upgrades in the last years effectless if they server did never get rebooted?
评论 #11910037 未加载
评论 #11909962 未加载
评论 #11910009 未加载
评论 #11912684 未加载
walrus01almost 9 years ago
For those saying &quot;why fail2ban?&quot;, fail2ban can be used for a great deal more than just watching the sshd log. You can activate fail2ban rules for apache and nginx which help significantly with small DDoS, turning spurious traffic&#x2F;login attempts into iptables DROP rules. And a lot of other daemons.
评论 #11913151 未加载
rodolphoarrudaalmost 9 years ago
I&#x27;d be more curious to see a &quot;My first 10 minutes on an Ubuntu desktop&quot; version of the article.
评论 #11911897 未加载
评论 #11914025 未加载
评论 #11910386 未加载
评论 #11910179 未加载
babuskovalmost 9 years ago
&gt; First we&#x27;ll want to make sure that we are supporting IPv6<p>How does that help security?
评论 #11914691 未加载
jboynycalmost 9 years ago
I&#x27;m finding that another important step is this one:<p>apt-get install etckeeper &amp;&amp; cd &#x2F;etc &amp;&amp; etckeeper init<p>Keeps your &#x2F;etc under version control so you know what kinds of configuration changes you&#x27;ve perpetrated.
评论 #11910280 未加载
评论 #11910110 未加载
tmalyalmost 9 years ago
I have been meaning to write up a similar guide.<p>I would like to recommend using just iptables instead of ufw, I had a case on my vps where an update to ufw failed and then the firewall was not working.<p>With iptables, install iptables-persistent package so they are saved when you do restarts. Do not try to block entire country ip ranges as this slows the machine down substantially.<p>fail2ban is great, I would recommend looking at some of your system logs to figure out new rules to add.
评论 #11910288 未加载
评论 #11910056 未加载
jtchangalmost 9 years ago
Why don&#x27;t they disable root logins with password period and only allow SSH key authentication?<p>Also if you put a passphase on your SSH key does that mean you have to enter it every time you want to SSH to the server (in order to unlock the key) or does it stay cached on most SSH clients (ssh on mac terminal, putty on windows, etc).<p>Isn&#x27;t watching failed logins kind of useless? I think it is more important to see what successful logins were made.
评论 #11910050 未加载
评论 #11909948 未加载
评论 #11909999 未加载
drzaiusapelordalmost 9 years ago
Its a tradition to nitpick these kinds of lists. Here&#x27;s my take.<p>&gt;I generally agree with Bryan that you&#x27;ll want to disable normal updates and only enable security updates.<p>Hmm, fairly certain the Ubuntu (and others) don&#x27;t do major product updates or API breaking updates via apt-get. You shouldnt have to worry about breaking anything if you use normal updates. This seems a bit too conservative for me and leads to problems down the line of being on an ancient or bugged library and then having to do the update manually later, usually after wasting a couple hours googling why $sexy_new_application isn&#x27;t working right on that server.<p>He setup an email alert, but not an smtp to actually send it. Also, OSSEC takes a few seconds to install and is much nicer than emailing full logs.<p>Lastly, fail2ban is becoming a sysadmin snake-oil&#x2F;fix-all. Its use is questionable in many circumstances. There&#x27;s a real chance of being locked out of your own server with this. If people are recommending it, they should be giving noob-friendly instruction to whitelist their IP at the very least.
taf2almost 9 years ago
Not sure if others feel this way but adding this line to sudo never felt right to me...<p>deploy ALL=(ALL) ALL<p>I usually instead limit the deploy user to a smaller subset of commands e.g. the init.d script to control a service.<p>obviously if someone gained access to deploy user we&#x27;re probably sol anyway... but it just makes it seem safer... we have a to login as an ops user to install or update things on the boxes.
评论 #11911126 未加载
评论 #11911839 未加载
kikimeteralmost 9 years ago
I created a script that does almost everything automatically using Ansible and Ansible Vault : <a href="https:&#x2F;&#x2F;github.com&#x2F;guillaumevincent&#x2F;Ansible-My-First-5-Minutes-On-A-Server" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;guillaumevincent&#x2F;Ansible-My-First-5-Minut...</a>
dawkinsalmost 9 years ago
I always worry that adding 2FA could make your machine inaccessible if anything happens to google-authenticator in this case. Maybe it&#x27;s a little bit of paranoia but I don&#x27;t like the idea of giving control over my ability to log into my server.
评论 #11910087 未加载
评论 #11910067 未加载
ameliusalmost 9 years ago
For protecting against brute-force login attempts, I use sshguard [1]<p>I really think this should be installed by default on distros like Ubuntu.<p>[1] <a href="http:&#x2F;&#x2F;www.sshguard.net&#x2F;" rel="nofollow">http:&#x2F;&#x2F;www.sshguard.net&#x2F;</a>
评论 #11911169 未加载
评论 #11909983 未加载
catmanjanalmost 9 years ago
One of the suggestions is to make sure your public key has the .pub extension, and they imply that if someone didn&#x27;t include the extension they would be reprimanded - any reason for this in particular?
评论 #11913975 未加载
usaphpalmost 9 years ago
&gt; &quot;You should never be logging on to a server as root.&quot;<p>Can someone explain me, let&#x27;s say I disabled password logins and only allow login via a key, what are potential downsides of logging in as a root?
评论 #11910237 未加载
SadWebDeveloperalmost 9 years ago
Forgot to check if the server isn&#x27;t backdoored. You will be surprised how many providers add many backdoors and monitoring systems you don&#x27;t need (m looking at you AWS guys).
Theodoresalmost 9 years ago
I would be annoyed with a cryptic Audi password. I would prefer &#x27;BatteryHorseStaple&#x27; passwords. Anything I can&#x27;t remember gets written on a post it note and put next to my screen with what it is for. This is my behaviour and the problem with cryptic passwords is that there are others like me, willing to keep a good password secret and not willing to be so secret about a clumsy, easy to crack by machine but impossible to remember password.
评论 #11911405 未加载
javajoshalmost 9 years ago
It may be useful, at step 0, to check out the server and see <i>basic server orientation</i>. Which Linux is it (cat &#x2F;etc&#x2F;*-release)? How much ram and disk (htop, df)? How is the filesystem setup (mount)? What packages are already installed (dpkg -l)? What processes are running (ps aux, htop)? What did the last root, including me, do (history)? I also like to know where is the box physically, roughly (tracert, run locally).
archon810almost 9 years ago
My biggest concern with being on a VPS like Linode, once you&#x27;re all done securing yourself and binding services to the local LAN IP, is an attack from within the network. The VPS you own is also accessible by others on the same subnet, contrary to what you might assume.<p>I&#x27;d love to see a ufw guide for whitelisting only your own internal IPs to be allowed access to any services for ultimate security.
评论 #11911730 未加载
评论 #11911892 未加载
overcastalmost 9 years ago
Very useful, most of this stuff is pretty common for anyone who has done any regular sysadmin work, but definitely good to have a checklist.
cleeusalmost 9 years ago
echo &quot;set background=dark&quot; &gt; &#x2F;etc&#x2F;vim&#x2F;vimrc.local
评论 #11909877 未加载
评论 #11909979 未加载
评论 #11910318 未加载
VLMalmost 9 years ago
Technically you don&#x27;t need the root password, you can always password recovery if you have access to the box. And how exactly did you lock yourself out of every account with sudo? Of course there&#x27;s always &quot;messed up my ldap or general network settings, can&#x27;t log in to fix them&quot;. There&#x27;s nothing wrong with setting your root password to a random string and throwing it away, after verifying your sudo works, I guess.<p>I will admit to being lazy, and with full automation its faster to spawn a new virtual image and let ansible run its course than to do root password recovery where you boot and tell the bootloader to make the init system &#x2F;bin&#x2F;sh and hand edit &#x2F;etc&#x2F;shadow and &#x2F;etc&#x2F;passwd and then reboot again, etc etc. I mean I can set up a new image almost as fast as I can reboot an old image, and I set up images a lot more often than I do password recovery, so...<p>Scrap the ssh commentary and set up ssh company wide as per stribika plus or minus local modifications:<p><a href="https:&#x2F;&#x2F;stribika.github.io&#x2F;2015&#x2F;01&#x2F;04&#x2F;secure-secure-shell.html" rel="nofollow">https:&#x2F;&#x2F;stribika.github.io&#x2F;2015&#x2F;01&#x2F;04&#x2F;secure-secure-shell.ht...</a><p>&quot;On large scale, you&#x27;ll be better off with a full automated setup using something like Ansible&quot;<p>At ANY scale you&#x27;re better off, unless you&#x27;re experimenting or time isn&#x27;t money. It&#x27;ll take longer to add the time to document and test what you&#x27;re doing by hand than to convince ansible to do it for you. If you don&#x27;t document or test you&#x27;re just doomed, so its not like you can avoid that effort. With automation this is like &quot;first two minutes on a server&quot; not ten.<p>Some people like to drop a .forward in root&#x27;s homedir sending mail to your sysadmin mailing list or yourself. I THINK but might be wrong that if you do that you don&#x27;t have to tell logwatch whom to email to, it&#x27;ll go to root then forward to the right people. More than logwatch assumes root@something.whatever exists as an email address.<p>You&#x27;re missing setting up your centralized rsyslog or local equivalent, your munin&#x2F;nagios&#x2F;zabbix or local equivalent... I still configure zabbix by hand because I&#x27;m old fashioned but its possible to automate that.<p>NTP is also missing. You can make Kerberos a very sad faced puppy if time isn&#x27;t synced. And its easy to set up to point to local trusted servers.<p>(Note, a post that&#x27;s nothing but complaining still means the linked article is at least 99.9% correct, it is a nicely written wide ranging TODO list)
评论 #11909997 未加载
评论 #11910293 未加载
thatusertwoalmost 9 years ago
I have a VPS, when I first got it, it had an additional user setup for some unknown reason. I didn&#x27;t know it was there until my server was hacked by a bot. I&#x27;d suggest adding one step of checking the &#x2F;home directory or other places to make sure no &#x27;unknown&#x27; accounts have been set up.
timroyalmost 9 years ago
Thanks for this article - very clear, well-motivated, and concise. I&#x27;m saving this for myself and others.
windsurferalmost 9 years ago
I guess I&#x27;m a pretty big noob, but why do people recommend so strongly on password protecting your private key? Losing it pretty much dooms you whether or not it&#x27;s password protected. It might get you a few hours or so to react and invalidate the public key, I guess...
评论 #11910865 未加载
ferossalmost 9 years ago
This is very similar to my &quot;How To Set Up Your Linode For Maximum Awesomeness&quot; guide:<p><a href="http:&#x2F;&#x2F;feross.org&#x2F;how-to-setup-your-linode&#x2F;" rel="nofollow">http:&#x2F;&#x2F;feross.org&#x2F;how-to-setup-your-linode&#x2F;</a>
z3t4almost 9 years ago
If you open up access from&#x2F;to port 80 or 443, you also open up access to all trojans&#x2F;spyware&#x2F;telemetry&#x2F;auto-update created in the last ten years. You&#x27;ll want to limit access per user and process.
agentgtalmost 9 years ago
It might nice if there were some cloud vendor specific addendums. For example on rackspace you almost always want to install the monitoring daemon (it&#x27;s actually fairly decent and small foot print).
dmouratialmost 9 years ago
Anyone remember Bastille Linux? <a href="https:&#x2F;&#x2F;help.ubuntu.com&#x2F;community&#x2F;BastilleLinux" rel="nofollow">https:&#x2F;&#x2F;help.ubuntu.com&#x2F;community&#x2F;BastilleLinux</a>
chrisperalmost 9 years ago
Instead of using unattended-upgrade, I prefer to subscribe to mailinglists and see when there are new securtiy updates.<p>One could combine that with something like rundeck where you run apt-get upgrade.
bikamonkialmost 9 years ago
Why not make a <i>certified</i> secured best practice 99% covered snapshot and share it as part of the one-click installs that most VPS providers offer nowadays?
a_imhoalmost 9 years ago
I think 2FA is generally bad practice and quite sad it is ubiquitous in e.g. banking and people try to shove it everywhere. It is analogous to password rules, 8-14 characters, numbers, capital letters and other signs. Yet it is very rare you can use a 40+ character passphrase. It gives a false sense of added security, while being annoying at the same time imo. It is very common, for me at least, not to have access to my phone all the time, because I left it at home, in the car etc. Not to mention if you lose it (or someone steals it) you have a huge pita to deal with.
评论 #11911717 未加载
PerfectElementalmost 9 years ago
Is there a similar guide for Windows servers out there?
评论 #11927876 未加载
ec109685almost 9 years ago
It would be useful to discuss what prevents the server from being rooted without a trace during the 10 minutes it takes to execute these steps.
评论 #11910133 未加载
评论 #11910513 未加载
评论 #11913327 未加载
评论 #11910278 未加载
mmgutzalmost 9 years ago
Hmmm ... why does root need a password? `sudo su`
评论 #11910887 未加载
Hello71almost 9 years ago
1.<p><pre><code> useradd -m deploy </code></pre> 2. &quot;PasswordAuthentication no&quot; probably won&#x27;t work as you expect if UsePAM is on.
brndnmgalmost 9 years ago
May I suggest Ansible or whatever other provisioning tool, you can subtract 9+ minutes from the title...
评论 #11913555 未加载
plusbryanalmost 9 years ago
What was wrong with 5 minutes? :-)
评论 #11915731 未加载
dewarrn1almost 9 years ago
Nice guide, better comments, leaving this here for later reference.
cfieberalmost 9 years ago
sure makes me glad all that (and so much more) happens in the first negative 10 minutes on any server I deploy.<p>If you are doing this after your server has launched you are doing it wrong.
tdalaaalmost 9 years ago
Pretty useful, thanks
stonogoalmost 9 years ago
No production server should ever be manually configured.
评论 #11911132 未加载
ck2almost 9 years ago
Don&#x27;t just change SSH key requirements, also change SSH port.<p>Port 22 is possibly the most heavily scanned port around.
nanisalmost 9 years ago
<i>Sigh</i> ... &quot;principal of least privilege&quot;
YngwieMalwarealmost 9 years ago
I&#x27;d been using this article for a couple years when I was a Linux server neophyte and now some of these things seem obvious to me. A good article for total noobs.
评论 #11911057 未加载