<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Linux Admin Zone &#187; Security</title>
	<atom:link href="http://linuxadminzone.com/category/security/feed/" rel="self" type="application/rss+xml" />
	<link>http://linuxadminzone.com</link>
	<description>Adding more reasons to celebrate Open Source.</description>
	<lastBuildDate>Wed, 09 May 2012 10:17:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Quickly upgrade ssh/openssh in CentOS Linux to latest 5.5 version</title>
		<link>http://linuxadminzone.com/quickly-upgrade-ssh-openssh-in-centos-linux-to-latest-5-5-version/</link>
		<comments>http://linuxadminzone.com/quickly-upgrade-ssh-openssh-in-centos-linux-to-latest-5-5-version/#comments</comments>
		<pubDate>Tue, 03 May 2011 15:18:45 +0000</pubDate>
		<dc:creator>jagbir</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://linuxadminzone.com/?p=382</guid>
		<description><![CDATA[In a CentOS 5.5 host, we were requested to upgrade openssh to its latest version. Here are steps I took to quickly do the upgrade. You may like to compile it from source or can take my way of installing it from some repository. Checking existing verison shows 4.3p2: $ ssh -v OpenSSH_4.3p2, OpenSSL 0.9.8e-fips-rhel5 [...]]]></description>
			<content:encoded><![CDATA[<p>In a CentOS 5.5 host, we were requested to upgrade openssh to its latest version. Here are steps I took to quickly do the upgrade. You may like to compile it from source or can take my way of installing it from some repository. </p>
<p>Checking existing verison shows 4.3p2:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">ssh</span> <span style="color: #660033;">-v</span>
OpenSSH_4.3p2, OpenSSL 0.9.8e-fips-rhel5 01 Jul <span style="color: #000000;">2008</span></pre></div></div>

<p>simply tried upgrading by running yum using default repositories but it didn&#8217;t find any latest version. To grab the latest one, I have installed the CentALT repository, which usually have latest packages. I&#8217;ve documented the steps to install it in earlier post <a href="http://linuxadminzone.com/upgrade-apachehttpd-to-2-2-17-in-centos-linux/">here</a>. After having installed CentALT, I tried again but found some dependency issue:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ yum upgrade openssh
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 <span style="color: #000000; font-weight: bold;">*</span> addons: mirrors.usc.edu
 <span style="color: #000000; font-weight: bold;">*</span> base: linux.mirrors.es.net
 <span style="color: #000000; font-weight: bold;">*</span> centosplus: mirror.stanford.edu
 <span style="color: #000000; font-weight: bold;">*</span> extras: linux.mirrors.es.net
 <span style="color: #000000; font-weight: bold;">*</span> updates: linux.mirrors.es.net
CentALT                                                                                                                     <span style="color: #000000; font-weight: bold;">|</span>  <span style="color: #000000;">951</span> B     00:00     
CentALT<span style="color: #000000; font-weight: bold;">/</span>primary                                                                                                             <span style="color: #000000; font-weight: bold;">|</span>  <span style="color: #000000;">85</span> kB     00:01     
CentALT                                                                                                                                    <span style="color: #000000;">256</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">256</span>
Excluding Packages <span style="color: #000000; font-weight: bold;">in</span> global exclude list
Finished
Setting up Upgrade Process
Resolving Dependencies
--<span style="color: #000000; font-weight: bold;">&gt;</span> Running transaction check
--<span style="color: #000000; font-weight: bold;">&gt;</span> Processing Dependency: openssh = 4.3p2-<span style="color: #000000;">72</span>.el5_6.3 <span style="color: #000000; font-weight: bold;">for</span> package: openssh-clients
--<span style="color: #000000; font-weight: bold;">&gt;</span> Processing Dependency: openssh = 4.3p2-<span style="color: #000000;">72</span>.el5_6.3 <span style="color: #000000; font-weight: bold;">for</span> package: openssh-server
---<span style="color: #000000; font-weight: bold;">&gt;</span> Package openssh.x86_64 <span style="color: #000000;">0</span>:5.5p1-<span style="color: #000000;">1</span>.el5 <span style="color: #000000; font-weight: bold;">set</span> to be updated
--<span style="color: #000000; font-weight: bold;">&gt;</span> Running transaction check
---<span style="color: #000000; font-weight: bold;">&gt;</span> Package openssh-clients.x86_64 <span style="color: #000000;">0</span>:5.5p1-<span style="color: #000000;">1</span>.el5 <span style="color: #000000; font-weight: bold;">set</span> to be updated
--<span style="color: #000000; font-weight: bold;">&gt;</span> Processing Dependency: libedit.so.0<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>64bit<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">for</span> package: openssh-clients
---<span style="color: #000000; font-weight: bold;">&gt;</span> Package openssh-server.x86_64 <span style="color: #000000;">0</span>:5.5p1-<span style="color: #000000;">1</span>.el5 <span style="color: #000000; font-weight: bold;">set</span> to be updated
--<span style="color: #000000; font-weight: bold;">&gt;</span> Finished Dependency Resolution
openssh-clients-5.5p1-<span style="color: #000000;">1</span>.el5.x86_64 from CentALT has depsolving problems
  --<span style="color: #000000; font-weight: bold;">&gt;</span> Missing Dependency: libedit.so.0<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>64bit<span style="color: #7a0874; font-weight: bold;">&#41;</span> is needed by package openssh-clients-5.5p1-<span style="color: #000000;">1</span>.el5.x86_64 <span style="color: #7a0874; font-weight: bold;">&#40;</span>CentALT<span style="color: #7a0874; font-weight: bold;">&#41;</span>
Error: Missing Dependency: libedit.so.0<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>64bit<span style="color: #7a0874; font-weight: bold;">&#41;</span> is needed by package openssh-clients-5.5p1-<span style="color: #000000;">1</span>.el5.x86_64 <span style="color: #7a0874; font-weight: bold;">&#40;</span>CentALT<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>little searching revealed its due to libedit library which we needs to bump up, got its rpm from phone.net and installed:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>src 
$ <span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #c20cb9; font-weight: bold;">ftp</span>:<span style="color: #000000; font-weight: bold;">//</span>ftp.pbone.net<span style="color: #000000; font-weight: bold;">/</span>mirror<span style="color: #000000; font-weight: bold;">/</span>atrpms.net<span style="color: #000000; font-weight: bold;">/</span>el5-x86_64<span style="color: #000000; font-weight: bold;">/</span>atrpms<span style="color: #000000; font-weight: bold;">/</span>stable<span style="color: #000000; font-weight: bold;">/</span>libedit0-<span style="color: #000000;">3.0</span>-1.20090722cvs.el5.x86_64.rpm
$ rpm <span style="color: #660033;">-ivh</span> libedit0-<span style="color: #000000;">3.0</span>-1.20090722cvs.el5.x86_64.rpm</pre></div></div>

<p>Then again tried upgrading openssh and its went fine:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ yum upgrade openssh
...
...
===================================================================================================================================================
 Package                                 Arch                           Version                              Repository                       Size
===================================================================================================================================================
Updating:
 openssh                                 x86_64                         5.5p1-<span style="color: #000000;">1</span>.el5                          CentALT                         <span style="color: #000000;">314</span> k
Updating <span style="color: #000000; font-weight: bold;">for</span> dependencies:
 openssh-clients                         x86_64                         5.5p1-<span style="color: #000000;">1</span>.el5                          CentALT                         <span style="color: #000000;">598</span> k
 openssh-server                          x86_64                         5.5p1-<span style="color: #000000;">1</span>.el5                          CentALT                         <span style="color: #000000;">328</span> k
&nbsp;
Transaction Summary
===================================================================================================================================================
Install       <span style="color: #000000;">0</span> Package<span style="color: #7a0874; font-weight: bold;">&#40;</span>s<span style="color: #7a0874; font-weight: bold;">&#41;</span>
Upgrade       <span style="color: #000000;">3</span> Package<span style="color: #7a0874; font-weight: bold;">&#40;</span>s<span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
Total download <span style="color: #c20cb9; font-weight: bold;">size</span>: <span style="color: #000000;">1.2</span> M</pre></div></div>

<p>Restart the sshd service and confirm new version:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>sshd restart
Stopping sshd:                                             <span style="color: #7a0874; font-weight: bold;">&#91;</span>  OK  <span style="color: #7a0874; font-weight: bold;">&#93;</span>
Starting sshd:                                             <span style="color: #7a0874; font-weight: bold;">&#91;</span>  OK  <span style="color: #7a0874; font-weight: bold;">&#93;</span>
&nbsp;
$ <span style="color: #c20cb9; font-weight: bold;">ssh</span> <span style="color: #660033;">-v</span>
OpenSSH_5.5p1, OpenSSL 0.9.8e-fips-rhel5 01 Jul <span style="color: #000000;">2008</span></pre></div></div>

<p>We are done.</p>
<p>You may also like other related articles on this blog:<br />
* <a href="http://linuxadminzone.com/quickly-change-your-ssh-port-from-default-22-to-something-higher/"> Quickly change your ssh port from defualt 22 to something higher </a><br />
* <a href="http://linuxadminzone.com/top-5-most-useful-commands-tools-for-linux-administrators/">Top 5 most useful tools for Linux Admin</a><br />
* <a href="http://linuxadminzone.com/5-steps-to-secure-your-linux-server/"> Top 5 steps to secure your production Linux host </a><br />
* <a href="http://linuxadminzone.com/ensuring-secure-access-to-production-linux-servers/"> Ensuring secure access to production Linux hosts </a><br />
* <a href="http://linuxadminzone.com/bash-script-to-backup-essential-log-files-of-linux-server/"> Bash script to backup essential log files in Linux Server </a><br />
* <a href="http://linuxadminzone.com/install-and-configure-denyhost/"> Install and Configure DenyHost to prevent brute-force attacks </a></p>
]]></content:encoded>
			<wfw:commentRss>http://linuxadminzone.com/quickly-upgrade-ssh-openssh-in-centos-linux-to-latest-5-5-version/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Quickly disable ssh version 1 in Linux</title>
		<link>http://linuxadminzone.com/quickly-disable-ssh-version-1-in-linux/</link>
		<comments>http://linuxadminzone.com/quickly-disable-ssh-version-1-in-linux/#comments</comments>
		<pubDate>Wed, 02 Mar 2011 15:46:35 +0000</pubDate>
		<dc:creator>jagbir</dc:creator>
				<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://linuxadminzone.com/?p=290</guid>
		<description><![CDATA[This is going to be very short post SSH v1 is not very safe and if you are looking to pass your site/server for PCI compliance then you must disable it. Don&#8217;t worry it is too easy to do. Open /etc/ssh/sshd_config file and disable version 1: $ vi /etc/ssh/sshd_config find line: #Protocol 2,1 and remove [...]]]></description>
			<content:encoded><![CDATA[<p>This is going to be very short post <img src='http://linuxadminzone.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  </p>
<p>SSH v1 is not very safe and if you are looking to pass your site/server for PCI compliance then you must disable it. Don&#8217;t worry it is too easy to do.<br />
Open /etc/ssh/sshd_config file and disable version 1:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">vi</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>ssh<span style="color: #000000; font-weight: bold;">/</span>sshd_config</pre></div></div>

<p>find line: <em>#Protocol 2,1</em> and remove 1 from it and then un-comment it, the final line should look like this:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>ssh<span style="color: #000000; font-weight: bold;">/</span>sshd_config <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> Protocol
Protocol <span style="color: #000000;">2</span></pre></div></div>

<p>Restart SSH service to apply changes.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ service sshd restart</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://linuxadminzone.com/quickly-disable-ssh-version-1-in-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>5 steps to secure your Linux server</title>
		<link>http://linuxadminzone.com/5-steps-to-secure-your-linux-server/</link>
		<comments>http://linuxadminzone.com/5-steps-to-secure-your-linux-server/#comments</comments>
		<pubDate>Wed, 16 Feb 2011 12:27:23 +0000</pubDate>
		<dc:creator>jagbir</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[Linux Security]]></category>

		<guid isPermaLink="false">http://linuxadminzone.com/?p=281</guid>
		<description><![CDATA[How would you ensure security of your production Linux Server? Should you can be happy with default configuration there in place or there&#8217;s are things which we must implement for enhancing security aspects? Of course, Yes. Here I&#8217;m writing 5 steps which I usually take to tighten security in Server. This doesn&#8217;t means these are [...]]]></description>
			<content:encoded><![CDATA[<p>How would you ensure security of your production Linux Server? Should you can be happy with default configuration there in place or there&#8217;s are things which we must implement for enhancing security aspects? Of course, Yes. Here I&#8217;m writing 5 steps which I usually take to tighten security in Server. This doesn&#8217;t means these are Best thing you can do or You don&#8217;t need to do anything else. There are many ways and remember securing your Server is a never ending process, So keep an eye open and check your Server regularly. </p>
<p><strong>Step 1. Disable direct root access. </strong><br />
Login should be allowed using simple/wheel user and then from there you can switch to root or use sudo to execute commands under root privileges. Let&#8217;s disable direct root login:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">vi</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>ssh<span style="color: #000000; font-weight: bold;">/</span>sshd_config
Look <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #ff0000;">&quot;PermitRootLogin yes&quot;</span> line <span style="color: #000000; font-weight: bold;">in</span> it and change it to <span style="color: #ff0000;">&quot;PermitRootLogin no&quot;</span>.</pre></div></div>

<p>Save the file, check for syntex and reload sshd service to make it effective:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ sshd <span style="color: #660033;">-D</span> <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>ssh<span style="color: #000000; font-weight: bold;">/</span>sshd_config
$ service sshd reload</pre></div></div>

<p>You can create a new user now which will be used for login, leave it if there&#8217;s already a user for this purpose. Don&#8217;t forget to have a strong password for root and for this user as well.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ useradd usertogetin
$ <span style="color: #c20cb9; font-weight: bold;">passwd</span> usertogetin</pre></div></div>

<p>Our step 1 is completed, but why it&#8217;s a necessary? A direct access to root user with a weak password is sure-shot invite for compromising security and get inside your server easily. Another powerful way to make it more difficult to hack in server is to change default ssh port 22 to something else, you can find the steps <a href="http://linuxadminzone.com/quickly-change-your-ssh-port-from-default-22-to-something-higher/">here</a> to do that.</p>
<p>You should also keep looking into security related logs like <strong>/var/log/secure</strong> for clue about possible attempt of logins from remote places. </p>
<p>Let me show you something:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">tail</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>secure
Feb  <span style="color: #000000;">6</span> 07:<span style="color: #000000;">41</span>:<span style="color: #000000;">56</span> ip-<span style="color: #000000;">184</span>-x-xx sshd<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">20421</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: Failed password <span style="color: #000000; font-weight: bold;">for</span> root from xx.xx.xx.xx port <span style="color: #000000;">48976</span> ssh2
Feb  <span style="color: #000000;">6</span> 07:<span style="color: #000000;">41</span>:<span style="color: #000000;">57</span> ip-<span style="color: #000000;">184</span>-x-xx-x sshd<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">20422</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: Received disconnect from xx.xx.xx.xx: <span style="color: #000000;">11</span>: Bye Bye
Feb  <span style="color: #000000;">6</span> 07:<span style="color: #000000;">41</span>:<span style="color: #000000;">57</span> ip-<span style="color: #000000;">184</span>-x-x-x sshd<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">20424</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: reverse mapping checking getaddrinfo <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #000000;">184</span>-xx-xx-xx.abcd.net failed - POSSIBLE BREAK-IN ATTEMPT<span style="color: #000000; font-weight: bold;">!</span></pre></div></div>

<p>It shows somebody is trying to get in your server by trying random password for root user. You can block such IPs but most important step is to block root access and use strong passwords.</p>
<p>Example of another instance:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">tail</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>secure
Feb  <span style="color: #000000;">6</span> 07:<span style="color: #000000;">46</span>:<span style="color: #000000;">58</span> ip-<span style="color: #000000;">184</span>-<span style="color: #000000;">168</span>-<span style="color: #000000;">71</span>-<span style="color: #000000;">156</span> sshd<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">20769</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: input_userauth_request: invalid user deathrun
Feb  <span style="color: #000000;">6</span> 07:<span style="color: #000000;">46</span>:<span style="color: #000000;">58</span> ip-<span style="color: #000000;">184</span>-<span style="color: #000000;">168</span>-<span style="color: #000000;">71</span>-<span style="color: #000000;">156</span> sshd<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">20768</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: pam_unix<span style="color: #7a0874; font-weight: bold;">&#40;</span>sshd:auth<span style="color: #7a0874; font-weight: bold;">&#41;</span>: check pass; user unknown
Feb  <span style="color: #000000;">6</span> 07:<span style="color: #000000;">46</span>:<span style="color: #000000;">58</span> ip-<span style="color: #000000;">184</span>-<span style="color: #000000;">168</span>-<span style="color: #000000;">71</span>-<span style="color: #000000;">156</span> sshd<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">20768</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: pam_unix<span style="color: #7a0874; font-weight: bold;">&#40;</span>sshd:auth<span style="color: #7a0874; font-weight: bold;">&#41;</span>: authentication failure; <span style="color: #007800;">logname</span>= <span style="color: #007800;">uid</span>=<span style="color: #000000;">0</span> <span style="color: #007800;">euid</span>=<span style="color: #000000;">0</span> <span style="color: #007800;">tty</span>=<span style="color: #c20cb9; font-weight: bold;">ssh</span> <span style="color: #007800;">ruser</span>= <span style="color: #007800;">rhost</span>=<span style="color: #000000;">184</span>.xx.xx.xx</pre></div></div>

<p>Here login attempts are done using random username and password. It implies that do not name your entry/wheel username as obvious one, choose somewhat difficult but what you can remember text for your username. Of course, Password must be strong which should includes chars,numbers and special symbols. </p>
<p>There should be mechanism to block an IP from where hacking/cracking/invalid/failed login attempts come from. If you see that there are 10s of failed login attempt from a particular IP address, then you should block it immediately. To facilitate this thing automatically, there a very good tool available, called as DenyHosts. I&#8217;ve already written an <a href="http://linuxadminzone.com/install-and-configure-denyhost/">article explaining how to</a> download/install/configure DenyHosts in Server. Its a must have package in any prod server.</p>
<p><strong>Step 2. Remove login shell from all other users except wheel user. </strong><br />
You have disabled the remote access to root but do you know through how many users, a person can get inside to your server? many application while installation creates their user but with a major security flaw, they set login shell to &#8216;bash&#8217; and this loophole can be exploited.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>ip-<span style="color: #000000;">184</span>-<span style="color: #000000;">168</span>-<span style="color: #000000;">71</span>-<span style="color: #000000;">156</span> log<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># grep 'bash' /etc/passwd</span>
root:x:<span style="color: #000000;">0</span>:<span style="color: #000000;">0</span>:root:<span style="color: #000000; font-weight: bold;">/</span>root:<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">bash</span>
usertogetin:x:<span style="color: #000000;">500</span>:<span style="color: #000000;">500</span>::<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>usertogetin:<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">bash</span></pre></div></div>

<p>Here you can see only two entries, which are fine but if you see more lines here like with users mysql, ftp, postgre etc. then please change shell of these users to nologin so by using these users, login can&#8217;t be done.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># usermod -s /sbin/nologin mysql</span></pre></div></div>

<p>Here we have modified shell of user MySQL from /bin/bash to /sbin/nologin. You should do this for other users as well except root and wheel user you created earlier. </p>
<p><strong>Step 3. Check open ports and stop unused services. </strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">netstat</span> <span style="color: #660033;">-ant</span>
Active Internet connections <span style="color: #7a0874; font-weight: bold;">&#40;</span>servers and established<span style="color: #7a0874; font-weight: bold;">&#41;</span>
Proto Recv-Q Send-Q Local Address               Foreign Address             State      
tcp        <span style="color: #000000;">0</span>      <span style="color: #000000;">0</span> <span style="color: #000000;">184</span>.xx.xx.xx:<span style="color: #000000;">53</span>             0.0.0.0:<span style="color: #000000; font-weight: bold;">*</span>                   LISTEN      
tcp        <span style="color: #000000;">0</span>      <span style="color: #000000;">0</span> <span style="color: #000000;">184</span>.xx.xx.xx:<span style="color: #000000;">53</span>             0.0.0.0:<span style="color: #000000; font-weight: bold;">*</span>                   LISTEN      
tcp        <span style="color: #000000;">0</span>      <span style="color: #000000;">0</span> 127.0.0.1:<span style="color: #000000;">53</span>                0.0.0.0:<span style="color: #000000; font-weight: bold;">*</span>                   LISTEN      
tcp        <span style="color: #000000;">0</span>      <span style="color: #000000;">0</span> 0.0.0.0:<span style="color: #000000;">21</span>                  0.0.0.0:<span style="color: #000000; font-weight: bold;">*</span>                   LISTEN      
tcp        <span style="color: #000000;">0</span>      <span style="color: #000000;">0</span> 0.0.0.0:<span style="color: #000000;">25</span>                  0.0.0.0:<span style="color: #000000; font-weight: bold;">*</span>                   LISTEN      
tcp        <span style="color: #000000;">0</span>      <span style="color: #000000;">0</span> :::<span style="color: #000000;">80</span>                       :::<span style="color: #000000; font-weight: bold;">*</span>                        LISTEN      
tcp        <span style="color: #000000;">0</span>      <span style="color: #000000;">0</span> :::<span style="color: #000000;">22</span>                       :::<span style="color: #000000; font-weight: bold;">*</span>                        LISTEN      
tcp        <span style="color: #000000;">0</span>      <span style="color: #000000;">0</span> :::<span style="color: #000000;">443</span>                      :::<span style="color: #000000; font-weight: bold;">*</span>                        LISTEN      
tcp        <span style="color: #000000;">0</span>      <span style="color: #000000;">0</span> ::ffff:xx.xx.xx.xx:<span style="color: #000000;">80</span>       ::ffff:xx.xx.xx.xx:<span style="color: #000000;">52502</span>    TIME_WAIT   
tcp        <span style="color: #000000;">0</span>   <span style="color: #000000;">3152</span> ::ffff:xx.xx.xx.xx:<span style="color: #000000;">22</span>       ::ffff:xx.xx.Xx.xx:<span style="color: #000000;">5222</span>     ESTABLISHED
..
..</pre></div></div>

<p>Apart from whatever showing above, your list may have many such lines with different ports with Listen/Established state. Here we used netstat command to list all active/listen/established ports with their IP addresses. You can see here some well known port numbers like 53 (DNS), 21 (FTP), 25 (SMTP), 80 (HTTP), 22 (SSH), 443 (HTTPS). These seems fine but if you doesn&#8217;t need any of these services, stop that program. In case you see some unusual listening ports, then you should verify their applications and stop them if they are not necessary. </p>
<p>Here by look at port numbers, you can&#8217;t get the information about which application is associated with any particular port number. Just for example, we want to know, which application is listening or using the port number 443. We can get this information by lsof command:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ lsof <span style="color: #660033;">-i</span> :<span style="color: #000000;">443</span>
<span style="color: #666666; font-style: italic;"># lsof -i :443</span>
COMMAND   PID   USER   FD   TYPE DEVICE SIZE NODE NAME
httpd    <span style="color: #000000;">4335</span> apache    6u  IPv6 <span style="color: #000000;">369447</span>       TCP <span style="color: #000000; font-weight: bold;">*</span>:https <span style="color: #7a0874; font-weight: bold;">&#40;</span>LISTEN<span style="color: #7a0874; font-weight: bold;">&#41;</span>
httpd    <span style="color: #000000;">6888</span>   root    6u  IPv6 <span style="color: #000000;">369447</span>       TCP <span style="color: #000000; font-weight: bold;">*</span>:https <span style="color: #7a0874; font-weight: bold;">&#40;</span>LISTEN<span style="color: #7a0874; font-weight: bold;">&#41;</span>
httpd    <span style="color: #000000;">7343</span> apache    6u  IPv6 <span style="color: #000000;">369447</span>       TCP <span style="color: #000000; font-weight: bold;">*</span>:https <span style="color: #7a0874; font-weight: bold;">&#40;</span>LISTEN<span style="color: #7a0874; font-weight: bold;">&#41;</span>
...
...</pre></div></div>

<p>So port 443 is used by httpd (Apache) application/process to provide secure http services. </p>
<p><strong>Step 4. Solid Backup Plan</strong><br />
Ensure that your server have a solid backup plan. All important files/databases/scripts etc. should be included in backup and it should be frequent. I have written a <a href="http://linuxadminzone.com/bash-script-to-backup-essential-log-files-of-linux-server/">script</a> which can help you to take frequent backup of essential log files/database. You can find it <a href="http://linuxadminzone.com/bash-script-to-backup-essential-log-files-of-linux-server/">here</a> with its usage. </p>
<p><strong>Step 5. Regular upgrades</strong><br />
Ensure that regular upgrades/security patches/fixes of packages must be applied on time to so that all known vulnerabilities are fixed. You can check sites like http://www.securityfocus.com/ for such vulnerabilities. </p>
<p>Installation of more advanced packages like SELinux and/or AppArmour and/or rootkit detection etc. will provide you higher level of security. </p>
<p>Please note that nothing can ensure a 100% secure server but the steps listed above can ensure that your server have adequate security mechanism in place. One more thing, if unfortunately your security in your Server get compromised then never trust that server as a cracker can have access to 100% of the system. In such cases where we don&#8217;t have 100% confidence that Server is ok, its better to rebuild the Server from scratch and restore backup to make it up again. </p>
<p>I&#8217;d appreciate your comments sharing your experience or approaches which can help us securing our Servers more effectively. </p>
]]></content:encoded>
			<wfw:commentRss>http://linuxadminzone.com/5-steps-to-secure-your-linux-server/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Ensuring secure access to Production Linux Servers</title>
		<link>http://linuxadminzone.com/ensuring-secure-access-to-production-linux-servers/</link>
		<comments>http://linuxadminzone.com/ensuring-secure-access-to-production-linux-servers/#comments</comments>
		<pubDate>Sun, 22 Aug 2010 06:04:38 +0000</pubDate>
		<dc:creator>jagbir</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[public/private keys]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://linuxadminzone.com/?p=245</guid>
		<description><![CDATA[I was amazed to hear from my friend that one of their server got hacked and reason may be that their part-time admin set password of root user as &#8216;admin&#8217;. Wow!! can&#8217;t believe it! They dont have right to cry about security attacks as they themselves keep their door opens I&#8217;ve suggested them some points [...]]]></description>
			<content:encoded><![CDATA[<p>I was amazed to hear from my friend that one of their server got hacked and reason may be that their part-time admin set password of root user as &#8216;admin&#8217;. Wow!! can&#8217;t believe it! They dont have right to cry about security attacks as they themselves keep their door opens <img src='http://linuxadminzone.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p> I&#8217;ve suggested them some points as per described below for ensuring secure access to servers. They have 5-6 Linux servers. This is obviously may not be the best way and I&#8217;m as always appreciate if you can give your suggestion in comments. My approach is that from 6 servers, we will be able to login only in 2 servers from remote through key based access and from these 2 server, we can access remaining. Here&#8217;s what we did:</p>
<p><strong>1. Disable root access</strong><br />
Completely disable root login access from remote. Period. Open <strong>/etc/ssh/sshd_config</strong> and add/remove comment from this line:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># vi /etc/ssh/sshd_config</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">PermitRootLogin no</pre></div></div>

<p><strong>2. Login only through non-root user </strong><br />
Create non-root user and create public/private key pair for it:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ adduser loginu</pre></div></div>

<p>login to &#8216;loginu&#8217; user created above, or if you are in root, just su:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># su loginu</span>
$ <span style="color: #c20cb9; font-weight: bold;">ssh-keygen</span> <span style="color: #660033;">-t</span> dsa</pre></div></div>

<p>Enter details while generating keys, enter good passphares and always remember it. Now you can go ahead and disable password based access completely so user can only login by using keys but this may be too restrictive or problematic for them if they forget passphares etc. if you want to go ahead, make sure these statements are there in /etc/ssh/sshd_config file:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">exit</span>
<span style="color: #666666; font-style: italic;"># vi /etc/ssh/sshd_config</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">PasswordAuthentication no
PubkeyAuthentication <span style="color: #c20cb9; font-weight: bold;">yes</span>
AuthorizedKeysFile      .ssh<span style="color: #000000; font-weight: bold;">/</span>authorized_keys</pre></div></div>

<p>copy the key you created earlier (there should be two files in ~loginu/.ssh/ directory: id_dsa, id_dsa.pub. so copy id_dsa) to your pc so from next time you can use this key to login into the server. </p>
<p>Just make sure you are able to login through &#8216;loginu&#8217; user before applying these ssh settings. Jump to terminal in your pc and try to login with key:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">ssh</span> <span style="color: #660033;">-i</span> id_dsa loginu<span style="color: #000000; font-weight: bold;">@</span>your.server.ip</pre></div></div>

<p>It will ask for passpahres and after supplying it you should be able to login into the server. Please make note that this is very confidential key and store it in good place/directory. Alternatively you can also generate keys in your own pc and store them at server to facilitate login. But if you want flexibility to have only one key (like carry it in your usb stick) and be able to login with it, I found this approach good to use server keys instead of pc keys. </p>
<p><strong>3. (Optional) Restrict login by IPs</strong><br />
Now come back in server. You can further strengthen security by allowing only select IPs to log in:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># vi /etc/ssh/sshd_config</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">AllowUsers loginu<span style="color: #000000; font-weight: bold;">@</span>aa.aa.aa.aa loginu<span style="color: #000000; font-weight: bold;">@</span>bb.bb.bb.bb loginu<span style="color: #000000; font-weight: bold;">@</span>cc.cc.cc.cc</pre></div></div>

<p>Here replace aa/bb/cc with actual IP addresses from where you want to allow access. </p>
<p>Going ahead, optionally, You can also change port for ssh from default 22 to other by using this <a href="http://linuxadminzone.com/quickly-change-your-ssh-port-from-default-22-to-something-higher/">guide</a> but as I think we are only allowing access through keys and from select remote places only, this you may skip. </p>
<p>Reload sshd daemon to apply settings which you have set in /etc/ssh/sshd_config by:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># service sshd reload</span></pre></div></div>

<p>Without closing current login session, try to login again from other terminal to check you are able to login into the server. </p>
<p><strong> 4. Secure other servers </strong><br />
As mentioned earlier, I preferred to treat first 2 server as &#8216;login&#8217; server in which we can login from anywhere using user &#8216;loginu&#8217; with key and then can login to other servers. So effectively other servers would not allow direct access from remote. Jump to server 3-6 and set following:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># vi /etc/ssh/sshd_config</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">AllowUsers loginu<span style="color: #000000; font-weight: bold;">@</span>aa.aa.aa.aa root<span style="color: #000000; font-weight: bold;">@</span>aa.aa.aa.aa loginu<span style="color: #000000; font-weight: bold;">@</span>bb.bb.bb. root<span style="color: #000000; font-weight: bold;">@</span>bb.bb.bb.bb</pre></div></div>

<p>here aa.aa/bb.bb indicates IP address of server #1 and #2 (login servers). So in this (#3) server we can login from those server(s) only. After making changes, reload ssh daemon to apply settings in all of these servers:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># service sshd reload</span></pre></div></div>

<p><strong> 5. Other services </strong><br />
I suggested to disable every service that we don&#8217;t need in servers. That&#8217;s the best approach to secure them <img src='http://linuxadminzone.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> . These servers has role of web servers and rsync process is there to sync files. In that case, created another non-root user:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># adduser rsyncuser</span></pre></div></div>

<p>generate keys (you can generate passphares less keys) for this user as well. Create same user in all other servers and put first server&#8217;s (from where rsync initiate) keys in them. Dont allow this user to login from remote but only from server where rsync initiate. I&#8217;ve documented rsync process <a href="http://linuxadminzone.com/script-to-sync-files-between-web-severs-having-plesk/">here</a>, if you want to go ahead and configure it. Similarly, if you need services like FTP then allow this only from selected IP address (by configuring /etc/hosts.allow) or firewall etc.</p>
<p><strong> 6. Configure DenyHosts </strong><br />
To further prevent attacks and block any IP address from which several failed login attempt originated, you should configure DenyHosts script ( I have documented howto on DenyHosts <a href="http://linuxadminzone.com/install-and-configure-denyhost/">here</a>) or equivalent.  </p>
<p>Other Most Read Articles:<br />
*  <a href="http://linuxadminzone.com/top-5-most-useful-commands-tools-for-linux-administrators/">Top 5 Linux commands for Administrators.</a><br />
* <a href="http://linuxadminzone.com/quick-howto-install-and-configure-munin-for-server-monitoring/">Install and configure Munin/Monitor for monitoring. </a><br />
* <a href="http://linuxadminzone.com/change-timezone-in-your-linux-server-quickly/ ">Change time zone in your Linux machine quickly.</a><br />
* <a href="http://linuxadminzone.com/detect-directory-or-file-changes-in-linuxunix/">Detect directory changes in Linux.</a><br />
* <a href="http://linuxadminzone.com/bash-script-to-backup-essential-log-files-of-linux-server/">Script to backup essential log files.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://linuxadminzone.com/ensuring-secure-access-to-production-linux-servers/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Here is why GoDaddy sucks in hosting, what about alternative?</title>
		<link>http://linuxadminzone.com/here-is-why-godaddy-sucks-in-hosting-what-about-alternative/</link>
		<comments>http://linuxadminzone.com/here-is-why-godaddy-sucks-in-hosting-what-about-alternative/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 17:24:57 +0000</pubDate>
		<dc:creator>jagbir</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[godaddy]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[malware]]></category>

		<guid isPermaLink="false">http://linuxadminzone.com/?p=218</guid>
		<description><![CDATA[Hosting my wordpress blog in GoDaddy was a big mistake, I realized this when one of my regular visitor alerted me that my blog is having suspicious activity. I promptly downloaded all of my blog files in my local system to scan and that operation took around 2 hours because of terrible FTP download rate [...]]]></description>
			<content:encoded><![CDATA[<p>Hosting my wordpress blog in GoDaddy was a big mistake, I realized this when one of my regular visitor alerted me that my blog is having suspicious activity. I promptly downloaded all of my blog files in my local system to scan and that operation took around 2 hours because of terrible FTP download rate from GoDaddy. Upon looking inside the files, almost all php files were having suspicious code and certainly infected by some malware. I did a clean of each and every file including database scan for any malicious records, users etc (referred <a href=" http://smackdown.blogsblogsblogs.com/2008/06/24/how-to-completely-clean-your-hacked-wordpress-installation/">this</a> while cleaning). Uploaded all new files by replacing existing completely. I checked my logs and thought for a while about why such thing happened. My wordpress version was latest, strong FTP password and in fact no regular FTP activities from my side. I&#8217;ve Mac for myself. So I didnt&#8217; found any reason and forgot that incident.</p>
<p>Suddenly after few days, same problem popped up. My friend complained that rss feed page of blog is not working. Now my eyebrow raised as I didn&#8217;t touched the site from my side since last cleanup (few days before) and entire blog files were again infected by that malware. Submitted a ticket with GoDaddy explaining everything but got lame response having points like We were unable to find any issue in your site, Make sure you are not running outdated version of blogging software blah blah.</p>
<p>When I searched over net about that issue, there were thousands of users having sites/blogs on GoDaddy who were facing same thing. I got many references/conversations like <a href=" http://wordpress.org/support/topic/godaddy-wordpress-blog-hacked">here</a> and <a href="http://blogcastfm.com/announcements/warning-massive-number-of-godaddy-wordpress-blogs-hacked-this-weekend/">here</a> indicating massive no. of users facing this issue. Whatever, I didn&#8217;t got any promising/supportive response from GoDaddy even after its very clear that hacking/malware spread was happened in their servers and instead of accepting and investigating, all they replying is crap.</p>
<p>This was a good indication for me to hunt another hosting provider and after lots of hunting, I zeroed down on nearlyfreespeech.net. These guys are simply awesome. Pay per usage plan, only SSH access (no FTP by default), very simple but intuitive interface and dirt cheap rates. I promptly shifted my personal/financial blog www.investorshine.com from GoDaddy to them and its now more than 3 months and honestly, I&#8217;m more than happy with them. Now going to shift this blog also very soon.</p>
<p>Just an update as on July, 2011, I&#8217;m running this blog on HostGator and very satisfied with their services.</p>
<p>At the end, GoDaddy lost one more customer having several domains and deluxe Linux hosting package. I will put all efforts to educate my friends as well to keep a distance from GoDaddy, at least as far as Hosting is concerned. Do you also have kind of same experience with GoDaddy? Please share here in comments for benefit of all community.</p>
]]></content:encoded>
			<wfw:commentRss>http://linuxadminzone.com/here-is-why-godaddy-sucks-in-hosting-what-about-alternative/feed/</wfw:commentRss>
		<slash:comments>50</slash:comments>
		</item>
	</channel>
</rss>

