LowEndBox - Cheap VPS, Hosting and Dedicated Server Deals

Bootstraping Low End VPS with Pre-built Scripts

It was fun setting up your very own server. I remembered the time when I received the root password to my very first virtual server back in March 2006 ($22/month for a merely 192MB of memory), it took me hours setting it up to exactly the way I wanted. At the end of the day when it started to pump out my websites on TCP port 80 — joy!

Well. It’s still fun the second time around when I moved hosting, but it wasn’t the same. 3rd time? Hmm. By now I probably have set up 30+ virtual servers due to expansion or migration, and it feels a lot like work than fun. In the effort to possess the 3 great virtues of a programmer according to Larry Wall, laziness, impatience, and hubris, I decided to write some simple scripts to quickly get my low end virtual servers up running and configured in no time!

Here is one that I want to share today.

Usage:

  1. Buy a new low end VPS from any provider
  2. Build a standard Debian 5 minimum install
  3. Got the root password
  4. ssh into your new low end box, and
    $ ssh root@my-new-box
    Linux lowendbox 2.6.18-blah #1 SMP Wed Aug 26 15:47:17 MSD 2009 i686
    ...
    Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
    permitted by applicable law.
    # wget -q https://lowendbox.com/scripts/lowend-debian.sh
    # bash ./lowend-debian.sh
    ...
    

What it does is:

  • Remove rsyslogd (memory hog on OpenVZ system) and portmap (mostly useless).
  • Run apt-get update && apt-get upgrade to get the server up to date.
  • Install and configure dash as /bin/sh.
  • Install and configure inetutils-syslog as default system logger.
  • Install and configure dropbear as OpenSSH replacement.

Once done, it should bring the memory usage to around 4-5MB on a 32bit Debian (where 2.8MB is from bash and dropbear that handles the SSH connection). It should also work on Ubuntu-based distributions (tested on a 64MB Ubuntu 9.04 VPS). Feel free to check the code to make sure I am not doing anything malicious like hijacking the server and install a ssh key or something :)

LEA
Latest posts by LEA (see all)

24 Comments

  1. Neves:

    Nice, but there is no security setup by default. What do you do?

    September 16, 2009 @ 3:26 am | Reply
  2. Download link is broken.
    …/scirpts/lowend-debian.sh
    should be
    …/scripts/lowend-debian.sh
    :)

    September 16, 2009 @ 3:42 am | Reply
  3. Arg. Link fixed.

    As of security — that really depends on your need (setting up sudoer, creating users, setting up firewalls). I have my scripts for those but I prefer not to show them :)

    September 16, 2009 @ 4:27 am | Reply
  4. Moi:

    You install inetutils-syslog as default syslogger, how do you think about limiting rsyslogd by using ulimit -s 128? Is it safe to do that?

    September 16, 2009 @ 7:07 am | Reply
  5. dne:

    Instead of “rm -rf /bin/sh”, I’d recommend “dpkg-divert –rename /bin/sh”.

    September 16, 2009 @ 7:19 am | Reply
  6. @Moi — the main issue I found with rsyslogd is its VSZ which is a lot greater than RSS. Although it might not use that much memory, it is still bad on an OpenVZ system where privvmpages counts the pages that are allocated.

    @dne — thanks for the suggestion.

    September 16, 2009 @ 8:22 am | Reply
  7. IWTFI:

    it will better to start some tutorial series, like:

    1) vps start configuration
    2) lighttpd and php install
    3) mysql and bind install
    4) postfix install and full configuration for virtual domains
    6) (whatever else you think)
    5) security tricks/tips

    let me know what you think.

    September 16, 2009 @ 2:39 pm | Reply
  8. IWTFI:

    btw something you forgot on the script..

    September 19, 2009 @ 1:41 pm | Reply
  9. Tyler:

    Thanks for this :)

    Btw you spelled virtues wrong :p (virues)

    November 9, 2009 @ 11:48 pm | Reply
  10. Thanks. Fixed. Last time I checked spelling was not in the list of virtues of programmers :)

    November 10, 2009 @ 1:05 am | Reply
  11. IWTFI:

    hey lowenbox. release more scripts!

    December 19, 2009 @ 9:39 pm | Reply
  12. cling[y]:

    Thanks for the script!

    December 20, 2009 @ 7:40 pm | Reply
  13. scotty:

    Thanks for the great script!

    I tried dropbear but it doesn’t play nice with git and none of the fixes I’ve seen work for me so I’ve abandoned it for just now.
    Seemingly the ulimit -s limit isn’t honoured by default ssh configurations, a bit of googling found me:

    UsePrivilegeSeparation = no

    Which will have ssh respecting your limits. Dropped ~3MB VSZ with that, google for the connotations.

    January 23, 2010 @ 11:44 pm | Reply
  14. Titus:

    Towards the end of the article, it is mentioned that once the softwares are installed by the scripts, the memory usage would drop to 4-5MB on a Debian 32 bit system . I bought an MICRO VPS plan (80 MB running Debian 5.0 32 Bit) from Quickweb , but even after i ran the script the top utility reports that i have used around 40000k memory, thats 40 MB . Should i be looking at any other utility to find out the right memory usage , or am i missing something here ?

    November 28, 2010 @ 6:42 pm | Reply
  15. OnlyDreamsNow:

    Thanks heaps, works great

    September 21, 2012 @ 10:43 am | Reply
  16. looks like bash and syslogd are still running after a reboot. is this correct?

    top – 21:28:47 up 16 min, 1 user, load average: 0.00, 0.00, 0.00
    Tasks: 12 total, 1 running, 11 sleeping, 0 stopped, 0 zombie
    Cpu(s): 0.0%us, 0.0%sy, 0.0%ni,100.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
    Mem: 131072k total, 30168k used, 100904k free, 0k buffers
    Swap: 131072k total, 0k used, 131072k free, 9288k cached

    PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
    1 root 20 0 2036 708 612 S 0.0 0.5 0:00.02 init
    2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd/30754
    3 root 20 0 0 0 0 S 0.0 0.0 0:00.00 khelper/30754
    350 root 20 0 1956 700 580 S 0.0 0.5 0:00.00 syslogd
    375 root 20 0 2092 484 380 S 0.0 0.4 0:00.00 dropbear
    383 daemon 20 0 2164 416 288 S 0.0 0.3 0:00.00 atd
    397 bind 20 0 51768 11m 2548 S 0.0 9.3 0:00.09 named
    419 root 20 0 46520 6944 2308 S 0.0 5.3 0:00.02 lwresd
    462 root 20 0 3792 768 600 S 0.0 0.6 0:00.00 cron
    491 root 20 0 2408 1124 860 S 0.0 0.9 0:00.23 dropbear
    492 root 20 0 4132 2832 1340 S 0.0 2.2 0:00.21 bash
    506 root 20 0 2336 1092 900 R 0.0 0.8 0:00.02 top

    September 24, 2012 @ 7:30 pm | Reply
  17. Blair:

    Thanks for this
    After doing this on the latest Debian package available,

    USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
    root 1 0.0 0.5 2028 704 ? Ss 07:01 0:00 init [2]
    root 2 0.0 0.0 0 0 ? S 07:01 0:00 [kthreadd/384]
    root 3 0.0 0.0 0 0 ? S 07:01 0:00 [khelper/384]
    root 459 0.0 0.4 1736 612 ? Ss 07:01 0:00 /sbin/syslogd
    root 492 0.0 0.6 8668 792 ? Ss 07:01 0:00 /usr/sbin/saslauthd -a pam -c -m /var/run/saslauthd -n 2
    root 495 0.0 0.2 8668 388 ? S 07:01 0:00 /usr/sbin/saslauthd -a pam -c -m /var/run/saslauthd -n 2
    root 501 0.0 0.7 5488 972 ? Ss 07:01 0:00 /usr/sbin/sshd
    root 536 0.0 0.6 2392 848 ? Ss 07:01 0:00 /usr/sbin/xinetd -pidfile /var/run/xinetd.pid -stayalive -inetd_compat -inetd_ipv6
    root 550 0.0 1.1 9988 1532 ? Ss 07:01 0:00 sendmail: MTA: accepting connections
    root 552 0.3 2.3 8544 3020 ? Ss 07:01 0:00 sshd: root@pts/0
    root 591 0.0 0.6 2288 864 ? Ss 07:01 0:00 /usr/sbin/cron
    root 617 0.0 1.2 2960 1604 pts/0 Ss 07:01 0:00 -bash
    root 627 0.0 0.7 2348 920 pts/0 R+ 07:02 0:00 ps aux

    I think I’m having the same issue as the guy above me, however, it did free up more then 40MB of my 128MB VPS, and now running at just over 95MB FREE with lighttpd and all the perks

    So I think it worked?

    November 30, 2012 @ 6:05 am | Reply
  18. MAXxATTAXx:

    Trying to port this to CentOS, but i cant figure out for the ssh part.

    im not sure how to remove old ssh to dropbear, and im afraid to get locke out of ssh :P

    got any idea?

    September 10, 2013 @ 12:06 pm | Reply
  19. brass9:

    Script is not found

    December 3, 2013 @ 8:20 am | Reply

Leave a Reply

Some notes on commenting on LowEndBox:

  • Do not use LowEndBox for support issues. Go to your hosting provider and issue a ticket there. Coming here saying "my VPS is down, what do I do?!" will only have your comments removed.
  • Akismet is used for spam detection. Some comments may be held temporarily for manual approval.
  • Use <pre>...</pre> to quote the output from your terminal/console, or consider using a pastebin service.

Your email address will not be published. Required fields are marked *