<?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>Technology Blog of Peter Manis &#187; Security</title>
	<atom:link href="http://pyverted.com/category/security/feed/" rel="self" type="application/rss+xml" />
	<link>http://pyverted.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Sat, 20 Feb 2010 22:03:54 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>First PGP Key Signing Party</title>
		<link>http://pyverted.com/security/first-pgp-key-signing-party/2010/01/</link>
		<comments>http://pyverted.com/security/first-pgp-key-signing-party/2010/01/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 06:09:21 +0000</pubDate>
		<dc:creator>Peter Manis</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[Key Signing]]></category>
		<category><![CDATA[PGP]]></category>
		<category><![CDATA[PIUS]]></category>

		<guid isPermaLink="false">http://pyverted.com/?p=436</guid>
		<description><![CDATA[Friday was my first time attending a PGP key signing party.  We had it in one of the buildings on campus and I thought I would share some of the commands I used to handle all the certificates.  I created a method for handling key signing parties while I did this one, but [...]]]></description>
			<content:encoded><![CDATA[<p>Friday was my first time attending a PGP key signing party.  We had it in one of the buildings on campus and I thought I would share some of the commands I used to handle all the certificates.  I created a method for handling key signing parties while I did this one, but I think this is a fairly good method.  What it basically does is keeps specific users in your pubring.gpg, while people at keysigning parties are in specific keyrings.  When defining them in your gpg.conf file they will be included in all of your GPG operations so it will be like they were in your pubring.gpg keyring.  It also means that if you don&#8217;t associate with anyone in the keysigning parting you can just comment out the file and still have the keys for later use or for archival purposes.</p>
<p>I first wanted to have these be in a specific keyring for the purposes of knowing who was at each keysigning.  To make sure your key gets added to the keyring you need to specify not to use the default keyring and use a specific keyring..  Make sure you include your keyid in the list of keys to pull from the keyserver as it will be needed when PIUS runs against the specific keyring.<br />
<span id="more-436"></span><br />
I added this to my ~/.gnupg/gpg.conf file so I can have all the keyrings included all the time.</p>
<pre><code># List of keyrings
# Key Signing Party, 2010-01-22
keyring keysign-20100122.gpg</code></pre>
<pre><code>touch ~/.gnupg/keysign-20100122.gpg
gpg --no-default-keyring --keyring keysign-20100122.gpg --recv-keys F6F08D6A ...</code></pre>
<p>With your key and the keys of the other participants in the new keyring download <a href="http://www.phildev.net/pius/" target="_blank">PIUS</a>, a tool written by a friend and coworker, Phil Dibowitz.  I preferred having it installed in ~/bin since that is added to my path automatically.</p>
<p>After it is installed run it against the keyring you created.  The example below works with Gmail/Google Apps mail accounts.</p>
<pre><code>KEYID="F6F08D6A"
USER="peter.manis@gmail.com"
MAIL="-P 587 -H smtp.gmail.com"
pius -s $KEYID -u $USER $MAIL -A -r keysign-20100122.gpg</code></pre>
<p>We had to add our key to the keysign-20100122.gpg keyring so PIUS would use it to sign keys.  So we don&#8217;t really need it in that keyring anymore.  The problem with removing it is that GPG requires the secret key be deleted first so we need to work around this.  Please <b>BACKUP</b> your files first so that if you make a mistake you don&#8217;t delete you entire keyring.</p>
<pre><code>touch ~/.gnupg/empty.gpg
gpg --no-default-keyring --secret-keyring empty.gpg --delete-key F6F08D6A</code></pre>
<p>My method for importing the keys was copying the PGP message in the email and saving it to a file with the extension &#8216;gpg&#8217;.  After that I was able to run the following for loop and import them all.</p>
<pre><code>for i in $(ls *.gpg); do cat $i | gpg -d | gpg --import; done</code></pre>
<p>Now you can send the key to the keyservers</p>
<pre><code>servers="x-hkp://pool.sks-keyservers.net pgp.mit.edu"
for server in $servers
    do gpg --keyserver $server --send-key F6F08D6A
done</code></pre>
<p>Over time you need to refresh your keys since the other people will have signatures added to their keys.</p>
<pre><code>gpg --refresh-keys</code></pre>
<p>If you need to refresh keys in files you don&#8217;t have in gpg.conf you can run this</p>
<pre><code>gpg --no-default-keyring --refresh-keys --keyring keysign-20100122.gpg</code></pre>
<p>UPDATE: I would recommend maybe setting a variable before starting this with the details that will be used multiple times and substitute it in the commands above.</p>
<pre><code>KEYID='F6F08D6A'
KEYRING=''keysign-20100122.gpg"</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://pyverted.com/security/first-pgp-key-signing-party/2010/01/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Locking down your server</title>
		<link>http://pyverted.com/sysadmin/locking-down-your-server/2008/10/</link>
		<comments>http://pyverted.com/sysadmin/locking-down-your-server/2008/10/#comments</comments>
		<pubDate>Mon, 20 Oct 2008 02:43:50 +0000</pubDate>
		<dc:creator>Peter Manis</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[Sys Admin]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Practices]]></category>
		<category><![CDATA[SSH]]></category>

		<guid isPermaLink="false">http://pyverted.com/?p=8</guid>
		<description><![CDATA[Update: I just thought about binding to a specific address to help prevent others from being able to ssh into a server.  This is similar to changing the port except that there are a limited number of ports, you could bind to xf1er.domain.com and it would be forever before someone was able to brute [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update</strong>: I just thought about binding to a specific address to help prevent others from being able to ssh into a server.  This is similar to changing the port except that there are a limited number of ports, you could bind to xf1er.domain.com and it would be forever before someone was able to brute force the address alone unless the DNS servers allowed zone transfers.  The best solution is to probably use a dedicated IP address for ssh, one that nothing else is using and that nothing can resolve to.  The reason is that say you had set ListenAddress to xf1er.domain.com if that resolves to the same IP as domain.com or www.domain.com it will still let you ssh in.  It is not like setting the address for a particular site in Apache, where it will actually need to match the domain name.</p>
<p>Recently someone on the SoCal LinuxUsers mailing list was asking for information, a checklist or sorts on procedures to lock down your Linux box when putting it on the big bad internet.  I will probably collect a lot more of these and make a real checklist, but this will get you started.  Note that some of the configuration directives for OpenSSH are already set by default, I prefer to make the change in the config file anyway to ensure those things are set.  You never know when an error might occur in an update and something could have been maliciously changed in the code or an accident happened.</p>
<ul>
<li>Install and Configure DenyHosts
<p>DenyHosts will add hosts to your /etc/hosts.deny file based on criteria you set and if you like it can download a file which is updated with hosts currently violating DenyHosts policies on other machines.  For a lot of services you have to run them in xinetd or inetd for TCP wrappers to work, without TCP wrappers being involved in the daemon hosts.deny/hosts.allow will do nothing for you.  The alternative to xinetd and inetd being involved is support for the libwrap library, which most OpenSSH packages have built in when compiled.  You can check if a daemon has libwrap support by following the guide on ducea.com ((<a href="http://www.ducea.com/2006/07/02/how-to-find-out-if-a-daemon-was-build-with-tcp-wrappers-support-hostsallowhostsdeny/" target="_blank">How to find out if a daemon was build with TCP Wrappers support</a>)).</p>
<p>All about Linux has a good post explaining how to use TCP wrappers to secure Linux ((All about Linux: <a href="http://linuxhelp.blogspot.com/2005/10/using-tcp-wrappers-to-secure-linux.html" target="_blank">Using TCP Wrappers to secure Linux</a>)).
</li>
<p><span id="more-8"></span></p>
<li>Remove root access via ssh
<p>You really shouldn&#8217;t be logging in as root anyway, but there are times when &#8217;sudo <i>command</i>&#8216; just is annoying.  If you really don&#8217;t need the audit trail &#8217;sudo su&#8217; will give you root access, but that should only be used when you have a large numbers of commands that need to be run as root and when you don&#8217;t need the audit trail.  You should never give someone the opportunity to brute force your root password, so adding this to /etc/ssh/sshd_config will disallow root from ever logging in through ssh.
<pre><code>PermitRootLogin no</code></pre>
<p>
</li>
<li>Set LoginGraceTime and MaxAuthTries
<p>These are good to add, but I feel with a lot of other things we are doing they aren&#8217;t a must.</p>
<pre>
<strong>LoginGraceTime</strong>
     The server disconnects after this time if the user has not suc-
     cessfully logged in.  If the value is 0, there is no time limit.
     The default is 120 seconds.

<strong>MaxAuthTries</strong>
     Specifies the maximum number of authentication attempts permitted
     per connection.  Once the number of failures reaches half this
     value, additional failures are logged.  The default is 6.
</pre>
<pre><code>LoginGraceTime 2m
MaxAuthTries 3</code></pre>
</li>
<li>Set MaxStartups
<p>Prevent the number of concurrent unauthenticated connections, this would slow down a brute force attack</p>
<pre>
<strong>MaxStartups</strong>
     Specifies the maximum number of concurrent unauthenticated con-
     nections to the SSH daemon.  Additional connections will be
     dropped until authentication succeeds or the LoginGraceTime ex-
     pires for a connection.  The default is 10.
</pre>
<pre><code>MaxStartups 3</code></pre>
</li>
<li>Set PermitEmptyPasswords
<p>It isn&#8217;t impossible for there to be a user with a blank password, mistakes happen, but this will prevent someone from logging in with that user.</p>
<pre><code>PermitEmptyPasswords no</code></pre>
</li>
<li>Set AllowUsers/AllowGroups in sshd_config
<p>By specifying what users are allowed to connect you are locking down the possibility of a successful brute force or dictionary attack on ssh, but this also helps prevent system access via a known internal username/password that really doesn&#8217;t need access via ssh.  An example would be if you had a user that services were running under and had permissions to certain things, but nobody really needed to directly login as that user.  So you can now add a user, say &#8216;johndoe&#8217; to AllowUsers and give him the password to another user say &#8217;sysadmin&#8217;, who happens to have the ability to sudo commands.  You have now just made it so that an attacker would have to gain access to two accounts to run a sudo command as the sysadmin user.  There are of course other things that an attacker could do to gain root/sudo access, but this is creating another layer of protection.  If you use the AllowGroups method you can have a group of users that can access the server via ssh, and just add and remove users as you need to without having to update and reload the sshd_config.</p>
<p>When specifying AllowUsers you can have a single username or a username and host.</p>
<div class="cmd">AllowUsers johndoe janedoe@10.10.10.1</div>
<p>  Specifying addresses will really help to secure who can login and where they can login from.  For my Endian box at home I have a user account linked to an IP address at work and separate non-privileged user with the IP address of a remote VPS.  I also have it linked to two IP addresses that are local to the machine.  You may ask why go through the trouble, but what this does for me is it allows me to login directly from my desktop and laptop while at home, and from my laptop while I am at work, but if I am at a remote location, say a friends house, I must first login to a VPS.  As we add a few more configuration changes to locking down the machine you will see how when these are combined it really helps prevent someone accessing the machine.</li>
<li>Turn on Public Key authentication for ssh
<p>The article I wrote for this was moved to this site, the title is SSH Public Key Authentication ((<a href="/sysadmin/ssh-public-key-authentication/2008/10/" target="_blank">SSH Public Key Authentication</a>))</li>
<li>Configure the firewall
<p>I avoid setting up mail as much as I can so my firewall rules are pretty limited.  I block drop all traffic except traffic on ports 22, 80 and 443.  If I have anything else running on the inside I access it using tunnels</li>
<li>Setup remote logging via syslogd
<p>If you have another server you can setup remote logging via syslogd or its variants.  The benefit of this is that if a machine was compromised the attacker would then have to compromise the server receiving the logs to remove the entries showing his attack on the machine.</li>
<li>Install Logwatch
<p>Install and enable logwatch and set it to the highest level of detail.  This will send you an email with login attempts, denyhost log entries, and a lot of good system information.  If someone breaks in the logs will be useless if they are good, but it is nice to receive an email letting you know what people are attempting to do and what is going on.</li>
<li>Setup various password rules.
<p>Ubuntu has a guide regarding user management ((<a href="https://help.ubuntu.com/8.04/serverguide/C/user-management.html" target="_blank">User Management</a>)), which will tell you how to setup password length rules and password expiration rules.</li>
<li>Check for rootkits
<p>Two really good tools for checking rootkits and some other various things on systems are chkrootkit and rkhunter.  I prefer rkhunter.</li>
</ul>
<p>There are tons of articles on securing systems all over the internet and I recommend you do some research on more methods of locking down a server it would be very hard for me to list everything you should/could do.  Intrusion detection, setting up jails, and so much more will help you secure your system, but don&#8217;t forget about the physical access to machines.  If someone has physical access to a machine they will most likely gain access to the system if they know what they are doing.</p>
]]></content:encoded>
			<wfw:commentRss>http://pyverted.com/sysadmin/locking-down-your-server/2008/10/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
