{"id":176,"date":"2011-09-10T12:49:20","date_gmt":"2011-09-10T04:49:20","guid":{"rendered":"http:\/\/thereforeiam.wordpress.com\/?p=176"},"modified":"2011-09-10T12:49:20","modified_gmt":"2011-09-10T04:49:20","slug":"vps-setting-up","status":"publish","type":"post","link":"https:\/\/www.brainfart.sg\/index.php\/2011\/09\/vps-setting-up\/","title":{"rendered":"VPS &#8211; Setting up"},"content":{"rendered":"<pre><span class=\"Apple-style-span\" style=\"font-family:Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;font-size:13px;line-height:19px;white-space:normal;\">I've logged in to my VPS and started setting it up.<\/span><\/pre>\n<p>Basically, the VPS has the following specs:<\/p>\n<ul>\n<li><strong>BuyVM-256MB<\/strong><\/li>\n<li>256MB RAM (Burstable to 512MB)<\/li>\n<li>2 Core CPU<\/li>\n<li>30GB of HDD<\/li>\n<li>1000GB of data transfer<\/li>\n<li>1 US based IP<\/li>\n<\/ul>\n<p>The VPS was first setup with BuyVM&#8217;s Centos 6 template (selected during the VPS ordering page). However, the memory usage \u00a0seems to be a little bit on the high side, roughly 30mb idling after I cleaned up the\u00a0unnecessary services and unused packages. No good&#8230; Still too much memory for running nothing&#8230;<\/p>\n<p>So the next thing I tried was to reinstall to their\u00a0&#8220;centos-5-i386-minimal&#8221;. After reinstalling, I can&#8217;t even ssh or console into the VPS&#8230; Resintalled again, still the same&#8230; Seems like that template is broken&#8230; No go.<\/p>\n<p>Reinstalled to &#8220;CentOS 5 32bit&#8221;, the idling memory shows ~14mb.<br \/>\nSweet! We are good to go!<!--more--><\/p>\n<p>The first thing I did, was to gather some baseline info from the VPS, to record down the state of the VPS basically. The commands I ran were:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nuname -a\ncat \/etc\/*release*\ncat \/etc\/hosts\nifconfig -a\nps fauxwww\nnetstat -tulpn\n<\/pre>\n<p>The first 4 command are pretty self explanatory.<br \/>\nThe forth one, &#8220;ps fauxwww&#8221;, list down the various processes in a tree form and shows the memory usage of each process. Very useful to determine what process is hogging memory.<br \/>\nThe last one, &#8220;netstat -tulpn&#8221;, list down the ports that the server is currently listening on and the process that is binding to the port. A useful tool to help secure your box.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n[root@server ~]# ps fauxwww\nUSER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND\nroot 1 0.0 0.1 2156 664 ? Ss Sep09 0:00 init [3]\nroot 1249 0.0 0.1 2260 556 ? S&amp;lt;s Sep09 0:00 \/sbin\/udevd -d\nroot 1895 0.0 0.1 1812 572 ? Ss Sep09 0:00 syslogd -m 0\nroot 1932 0.0 0.1 2832 852 ? Ss Sep09 0:00 xinetd -stayalive -pidfile \/var\/run\/xinetd.pid\nroot 1976 0.0 0.2 4492 1100 ? Ss Sep09 0:00 crond\nroot 1984 0.0 0.1 5680 700 ? Ss Sep09 0:00 \/usr\/sbin\/saslauthd -m \/var\/run\/saslauthd -a pam -n 2\nroot 1985 0.0 0.0 5680 440 ? S Sep09 0:00 _ \/usr\/sbin\/saslauthd -m \/var\/run\/saslauthd -a pam -n 2\nroot 3483 0.0 0.2 7200 1060 ? Ss Sep09 0:00 \/usr\/sbin\/sshd\nroot 3863 0.1 0.5 10036 2836 ? Ss 08:02 0:00 _ sshd: keewee [priv]\nkeewee 3865 0.0 0.3 10036 1672 ? S 08:03 0:00 _ sshd: keewee@pts\/0\nkeewee 3866 0.0 0.2 3712 1500 pts\/0 Ss 08:03 0:00 _ -bash\nroot 3883 0.0 0.2 4092 1316 pts\/0 S 08:03 0:00 _ su -\nroot 3884 0.1 0.2 3712 1488 pts\/0 S 08:03 0:00 _ -bash\nroot 3903 0.0 0.1 2528 848 pts\/0 R+ 08:03 0:00 _ ps fauxwww\n\n[root@server ~]# netstat -tulpn\nActive Internet connections (only servers)\nProto Recv-Q Send-Q Local Address Foreign Address State PID\/Program name\ntcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1949\/sendmail: acce\ntcp 0 0 :::80 :::* LISTEN 1967\/httpd\ntcp 0 0 :::22 :::* LISTEN 1923\/sshd\n<\/pre>\n<p>Combined, these two command can also help you determine what services to disable and what packages to uninstall.<\/p>\n<p>After gathering the information, I started setting up the server.<br \/>\nI started off with some basic server security, creating a non-root user for logging in and securing SSH.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n#Create Nonroot User\n[root@server ~]# groupadd keewee\n[root@server ~]# useradd -d \/home\/keewee -s \/bin\/bash -g keewee -m keewee\n\n#Secure SSH\n[root@server ~]# vi \/etc\/ssh\/sshd_config\n#Uncomment the following\nLoginGraceTime 5m\nPermitRootLogin no\nStrictModes yes\nMaxAuthTries 6\nUsePrivilegeSeparation yes\n\n[root@server ~]# service sshd restart\n<\/pre>\n<p>The next thing was to remove all the unnecessary packages, packages that I didn&#8217;t need or don&#8217;t use and is not essential to the operation of the box.<br \/>\nFor this, I referred to to the &#8220;ps fauxwww&#8221; and &#8220;netstat -tulpn&#8221; output. I didn&#8217;t need sendmail and apache (httpd), so I chucked those.<br \/>\nI also went through the list of installed package by issuing &#8220;yum list installed&#8221; and picking out the packages I don&#8217;t want.<br \/>\nI ended up with the following packages to remove:<\/p>\n<ul>\n<li>bind<\/li>\n<li>fetchmail<\/li>\n<li>finger-server<\/li>\n<li>httpd<\/li>\n<li>lynx<\/li>\n<li>portmap<\/li>\n<li>procmail<\/li>\n<li>samba<\/li>\n<li>sendmail<\/li>\n<li>talk-server<\/li>\n<\/ul>\n<div>That&#8217;s all I&#8217;ve done so far. Now my memory usage when logged in via SSH is ~13mb and when it is idling without running anything, ~6mb. Nice!<br \/>\nOn my next post, I will be sharing the setting up of the LNMP software stack.<\/div>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve logged in to my VPS and started setting it up. Basically, the VPS has the following specs: BuyVM-256MB 256MB RAM (Burstable to 512MB) 2 Core CPU 30GB of HDD 1000GB of data transfer 1 US based IP The VPS&hellip; <a href=\"https:\/\/www.brainfart.sg\/index.php\/2011\/09\/vps-setting-up\/\" class=\"more-link\">Continue Reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"aside","meta":{"spay_email":""},"categories":[17],"tags":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p1T66h-2Q","jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.brainfart.sg\/index.php\/wp-json\/wp\/v2\/posts\/176"}],"collection":[{"href":"https:\/\/www.brainfart.sg\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.brainfart.sg\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.brainfart.sg\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.brainfart.sg\/index.php\/wp-json\/wp\/v2\/comments?post=176"}],"version-history":[{"count":0,"href":"https:\/\/www.brainfart.sg\/index.php\/wp-json\/wp\/v2\/posts\/176\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.brainfart.sg\/index.php\/wp-json\/wp\/v2\/media?parent=176"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.brainfart.sg\/index.php\/wp-json\/wp\/v2\/categories?post=176"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.brainfart.sg\/index.php\/wp-json\/wp\/v2\/tags?post=176"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}