<?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; Sys Admin</title>
	<atom:link href="http://pyverted.com/category/sysadmin/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>Double Bang</title>
		<link>http://pyverted.com/sysadmin/double-bang/2008/11/</link>
		<comments>http://pyverted.com/sysadmin/double-bang/2008/11/#comments</comments>
		<pubDate>Mon, 17 Nov 2008 02:16:23 +0000</pubDate>
		<dc:creator>Peter Manis</dc:creator>
				<category><![CDATA[Sys Admin]]></category>
		<category><![CDATA[Commands]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://pyverted.com/?p=123</guid>
		<description><![CDATA[No I&#8217;m not excited about sudo, well I sorta am.  I have run into situations where I typed a long command and forgot to type sudo.  This is a huge problem when you can&#8217;t hit the home key and go to the start of the command, which happens in a lot of SSH [...]]]></description>
			<content:encoded><![CDATA[<p>No I&#8217;m not excited about sudo, well I sorta am.  I have run into situations where I typed a long command and forgot to type sudo.  This is a huge problem when you can&#8217;t hit the home key and go to the start of the command, which happens in a lot of SSH tools.</p>
<p>The Fix!!!</p>
<pre><code>sudo !!</code></pre>
<p>Typing that will execute the last command, but it will execute it as if you had typed sudo at the beginning.  This is a huge time saver.</p>
]]></content:encoded>
			<wfw:commentRss>http://pyverted.com/sysadmin/double-bang/2008/11/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bang Asterisk</title>
		<link>http://pyverted.com/sysadmin/bang-asterisk/2008/11/</link>
		<comments>http://pyverted.com/sysadmin/bang-asterisk/2008/11/#comments</comments>
		<pubDate>Mon, 17 Nov 2008 02:08:00 +0000</pubDate>
		<dc:creator>Peter Manis</dc:creator>
				<category><![CDATA[Sys Admin]]></category>
		<category><![CDATA[Commands]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://pyverted.com/?p=117</guid>
		<description><![CDATA[Similar to the double bang trick is bang+asterisk.  This combinations takes just the parameters from the previous command.
[user@host ~]$ ls /home
user
[user@host ~]$ cd !*
cd /home
[user@host home]$ 
Enjoy!
]]></description>
			<content:encoded><![CDATA[<p>Similar to the <a href="http://pyverted.com/sysadmin/double-bang/2008/11/">double bang</a> trick is bang+asterisk.  This combinations takes just the parameters from the previous command.</p>
<pre><code>[user@host ~]$ ls /home
user
[user@host ~]$ cd !*
cd /home
[user@host home]$ </code></pre>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://pyverted.com/sysadmin/bang-asterisk/2008/11/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Work Environment</title>
		<link>http://pyverted.com/sysadmin/work-environment/2008/11/</link>
		<comments>http://pyverted.com/sysadmin/work-environment/2008/11/#comments</comments>
		<pubDate>Sun, 16 Nov 2008 16:56:48 +0000</pubDate>
		<dc:creator>Peter Manis</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Sys Admin]]></category>
		<category><![CDATA[Applications]]></category>
		<category><![CDATA[Consulting]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Environment]]></category>

		<guid isPermaLink="false">http://pyverted.com/?p=109</guid>
		<description><![CDATA[I have noticed a few people have been commenting on their development environments and wanted to chime in on what I use when I am consulting or working on a personal project.
Internet Based:

Dropbox &#8211; This application allows me to share files between all of my platforms.  It works very similar to how subversion works, [...]]]></description>
			<content:encoded><![CDATA[<p>I have noticed a few people have been commenting on their development environments and wanted to chime in on what I use when I am consulting or working on a personal project.</p>
<p><strong>Internet Based</strong>:</p>
<ul>
<li><a href="http://www.getdropbox.com/" target="_blank">Dropbox</a> &#8211; This application allows me to share files between all of my platforms.  It works very similar to how subversion works, but commits the files automatically after they have been added to the directory.  They are stored encrypted on the Dropbox servers so the information is safe from prying eyes.</li>
<li><a href="http://twitter.com/petermanis" target="_blank">Twitter</a> &#8211; I never got the whole twitter thing for a long time, but it is nice to know what my friends are up to.</li>
<li><a href="http://www.facebook.com/profile.php?id=516407504" target="_blank">Facebook</a> &#8211; Probably the only decent social networking site out there</li>
<li><a href="http://www.linkedin.com/in/manis" target="_blank">LinkedIn</a> &#8211; Business social networking.</li>
<li><a href="http://del.icio.us/petermanis" target="_blank">del.icio.us</a> &#8211; Social bookmarking.</li>
<li><a href="http://pownce.com/manis/" target="_blank">Pownce</a> &#8211; Similar to twitter, but does more for media sharing.</li>
</ul>
<p><span id="more-109"></span></p>
<p><strong>On the Desktop</strong>:</p>
<ul>
<li><a href="http://www.eclipse.org/" target="_blank">Eclipse</a> with <a href="http://pydev.sourceforge.net" target="_blank">Pydev</a> &#8211; I have done a lot of switching of IDEs, I sometimes go back to <a href="http://www.activestate.com/Products/komodo_ide/komodo_edit.mhtml" target="_blank">Komodo Edit</a>, but for the most part I have found Pydev to be one of the best IDEs for Python development</li>
<li><a href="http://macromates.com/" target="_blank">Textmate</a> &#8211; For a lot of things I hate Textmate.  For a long time I was against code completion, but lacking drop down code completion is something I dislike a great deal about Textmate.  I have found Textmate to be great for editing JSON by hand, and for a quick edit on pretty much any type of source.  It also happens to be the best &#8220;notepad&#8221; alternative on the Mac.  What I use Textmate for most of all is notes.  I have a few directories and I run &#8220;mate&#8221; on it giving me a great environment for keeping notes.</li>
<li><a href="http://www.zend.com/en/products/studio/" target="_blank">Zend Studio for Eclipse</a> &#8211; I use Zend Studio for almost all of my PHP development.  It is a fantastic product and the only times I don&#8217;t really use it are when I have a quick edit to make.  In those cases I usually pick Textmate (on the Mac) and UltraEdit (on Windows)</li>
<li><a href="http://www.ultraedit.com/" target="_blank">UltraEdit</a> &#8211; UltraEdit doesn&#8217;t have drop down completions or a lot of other fancy IDE features, for it is a super powerful editor and I have been using it for about 6 years now and don&#8217;t plan on stopping.  It took time getting used to it, but once I did I find myself using it for more than I ever thought I would.</li>
<li><a href="http://tortoisesvn.tigris.org/" target="_blank">TortoiseSVN</a> &#8211; The best subversion client you can find.  I have tried a lot of the ones for Mac and Windows and I really haven&#8217;t found on that works as well or gives just the right features as TortoiseSVN.</li>
<li><a href="http://www.flashfxp.com/" target="_blank">FlashFXP</a> &#8211; I rarely use FTP, but when I do FlashFXP is my choice.  I wish it included SFTP/SSH support, but hopefully they will do a rewrite at some point and it will be included.</li>
<li><a href="http://www.scootersoftware.com/" target="_blank">Beyond Compare</a> &#8211; Probably the best text comparison tool I have ever used.  In addition to comparing file contents you can do various checks on file themselves, which helps when comparing directories full of files.</li>
<li><a href="http://www.analogx.com/CONTENTS/download/system/capture.htm" target="_blank">AnalogX Capture</a> &#8211; I use this to capture website designs that motivate me or inspire me.</li>
<li><a href="http://www.microsoft.com/windows/windows-xp/" target="_blank">Windows XP</a> &#8211; My primary desktop runs Windows, and while so many have so much to say about an operating system they know very little about tuning and maintaining I still enjoy using Windows for many tasks.</li>
<li><a href="http://www.apple.com/macosx/" target="_blank">Mac OS X, Leopard</a> &#8211; My work laptop is a Mac Book Pro running Leopard, and I enjoy using it more than any other system so I find myself doing a decent amount of work on it.</li>
<li><a href="http://www.ubuntu.com/" target="_blank">Ubuntu</a> &#8211; As for a Linux desktop I use Ubuntu since it saves time getting things setup and there is a lot of software available for the distro.</li>
<li><a href="http://www.mozilla.com/en-US/products/firefox/" target="_blank">Firefox</a> &#8211; One of the best browsers, and super awesome on Mac OS X.</li>
<li><a href="http://www.videolan.org/vlc/" target="_blank">VLC</a> &#8211; Video player that handles playing DVD ISOs directly and supports virtually any format.</li>
<li><a href="http://www.vienna-rss.org/vienna2.php" target="_blank">Vienna</a> &#8211; Feed reader for Mac OS.</li>
<li><a href="http://culturedcode.com/things/" target="_blank">Things</a> &#8211; Todo list application with a lot of features.</li>
<li><a href="http://iterm.sourceforge.net/" target="_blank">iTerm</a> &#8211; Terminal application for Mac OS.</li>
<li><a href="http://www.adiumx.com/" target="_blank">AdiumX</a>/<a href="http://pidgin.im/" target="_blank">Pidgin</a> &#8211; Multi service chat clients</li>
<li><a href="http://www.xchat.org/" target="_blank">XChat</a>/<a href="http://sourceforge.net/projects/xchataqua/" target="_blank">XChat Aqua</a> &#8211; One of the best IRC clients, and the Mac OS port of it.</li>
<li><a href="http://fuse.sourceforge.net/sshfs.html" target="_blank">sshfs</a>/<a href="http://code.google.com/p/macfuse/" target="_blank">MacFUSE</a> &#8211; sshfs is one of the greatest tools, you&#8217;ll never need a sftp client again.</li>
<li><a href="http://iconfactory.com/software/twitterrific" target="_blank">Twitterific</a> &#8211; Mac OS twitter client</li>
<li><a href="http://www.gnu.org/software/screen/" target="_blank">screen</a> &#8211; Essential tool for anyone working on Unix/Linux systems.  Allows you to detach a session and disconnect while keeping your session active on the system.</li>
<li><a href="http://www.gnu.org/software/bash/manual/bashref.html" target="_blank">bash</a> &#8211; No explanation needed</li>
<li><a href="http://www.transmissionbt.com/" target="_blank">Transmission</a> &#8211; Bit torrent client for Mac OS.  Supports IP block lists.</li>
<li><a href="http://vmware.com/products/fusion/" target="_blank">VMware Fusion</a> &#8211; Virtualization software for Mac OS.</li>
<li>ssh/scp/sftp &#8211; Remote terminal, file transfer.</li>
</ul>
<p><strong>On the Server</strong>:</p>
<ul>
<li><a href="http://www.danga.com/memcached/" target="_blank">memcached</a> &#8211; A high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load.</li>
<li><a href="http://httpd.apache.org/" target="_blank">Apache</a> &#8211; Web server that has stood the test of time and handles significant traffic.</li>
<li><a href="http://subversion.tigris.org/" target="_blank">Subversion</a>/mod_dav_svn &#8211; Popular revision control</li>
<li><a href="http://djangoproject.com/" target="_blank">Django</a>/<a href="http://www.modpython.org/" target="_blank">mod_python</a> &#8211; Python web framework and the Apache module that can handle heavy work load.</li>
<li><a href="http://www.php.net" target="_blank">PHP</a> &#8211; Don&#8217;t need to explain this one</li>
<li><a href="http://www.mysql.com" target="_blank">MySQL</a> &#8211;  Or this one.</li>
<li><a href="http://lucene.apache.org/solr/" target="_blank">Solr</a> &#8211; Lucene based index software.  Very fast, and fairly easy to configure and use.</li>
<li><a href="http://www.gnu.org/software/screen/" target="_blank">screen</a>, <a href="http://www.gnu.org/software/bash/manual/bashref.html" target="_blank">bash</a>, ssh, and sftp are also used on the server.</li>
</ul>
<p><strong>Planned for the Future</strong>:</p>
<ul>
<li><a href="http://www.postgresql.org/" target="_blank">PostgreSQL</a> &#8211; PostgreSQL is a powerful, open source relational database system. It has more than 15 years of active development and a proven architecture that has earned it a strong reputation for reliability, data integrity, and correctness.</li>
<li><a href="http://www.pgadmin.org/" target="_blank">pgAdmin III</a> &#8211; The most popular and feature rich Open Source administration and development platform for PostgreSQL</li>
<li><a href="http://varnish.projects.linpro.no/" target="_blank">Varnish</a> &#8211; Varnish is a state-of-the-art, high-performance HTTP accelerator. It uses the advanced features in Linux 2.6, FreeBSD 6/7 and Solaris 10 to achieve its high performance.</li>
<li><a href="http://www.nongnu.org/fab/" target="_blank">Fabric</a> &#8211; Fabric is like the Python capistrano</li>
<li><a href="http://www.capify.org/" target="_blank">Capistrano</a> &#8211; Capistrano is a tool for automating tasks on one or more remote servers. It executes commands in parallel on all targeted machines, and provides a mechanism for rolling back changes across multiple machines.</li>
<li><a href="http://www.apsis.ch/pound/" target="_blank">Pound</a>, <a href="http://www.danga.com/perlbal/" target="_blank">Perlbal</a>, and <a href="http://nginx.net/" target="_blank">Nginx</a> &#8211; Reverse proxy load balancer and web servers</li>
<li><a href="http://code.google.com/p/modwsgi/" target="_blank">mod_wsgi</a> &#8211; What appears to be a better what to run Django in Apache</li>
<li><a href="http://activemq.apache.org/" target="_blank">ActiveMQ</a> &#8211; Popular and powerful open source Message Broker and Enterprise Integration Patterns provider.</li>
<li><a href="http://www.sun.com/software/solaris/" target="_blank">Solaris</a> and <a href="http://opensolaris.org/os/" target="_blank">OpenSolaris</a> &#8211; Unix-based operating system introduced by Sun Microsystems in 1992 as the successor to SunOS.</li>
<li><a href="http://github.com/dcramer/django-debug-toolbar/tree/master" target="_blank">Django Debug Toolbar</a> &#8211; The Django Debug Toolbar is a configurable set of panels that display various debug information about the current request/response.</li>
<li><a href="http://git.or.cz/" target="_blank">Git</a> &#8211; Open source version control system designed to handle very large projects with speed and efficiency, but just as well suited for small personal repositories</li>
<li><a href="http://sourceforge.net/projects/shelled" target="_blank">ShellEd</a> &#8211; ShellEd is a superb shell script editor for Eclipse. The great benefit of this plugin is the integration of man page information for content assist and text hover.</li>
<li><a href="http://www.erlang.org/" target="_blank">Erlang</a> &#8211; Erlang is a programming language designed at the Ericsson Computer Science Laboratory.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://pyverted.com/sysadmin/work-environment/2008/11/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>
		<item>
		<title>SSH Public Key Authentication</title>
		<link>http://pyverted.com/sysadmin/ssh-public-key-authentication/2008/10/</link>
		<comments>http://pyverted.com/sysadmin/ssh-public-key-authentication/2008/10/#comments</comments>
		<pubDate>Mon, 20 Oct 2008 02:15:39 +0000</pubDate>
		<dc:creator>Peter Manis</dc:creator>
				<category><![CDATA[Sys Admin]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[SSH]]></category>

		<guid isPermaLink="false">http://pyverted.com/?p=25</guid>
		<description><![CDATA[The first thing we need to do is create the public key.  For this post we will use localmach for the local machine and remotemach for the remote machine.
Before beginning the following should be set on the remotemach in /etc/ssh/sshd_config
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile     .ssh/authorized_keys

On the local machine type the following
ssh-keygen -t [...]]]></description>
			<content:encoded><![CDATA[<p>The first thing we need to do is create the public key.  For this post we will use localmach for the local machine and remotemach for the remote machine.</p>
<p>Before beginning the following should be set on the remotemach in /etc/ssh/sshd_config</p>
<pre><code>RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile     .ssh/authorized_keys</code></pre>
<p><span id="more-25"></span></p>
<p>On the local machine type the following</p>
<pre><code>ssh-keygen -t rsa -b 2048</code></pre>
<p>This will create a 2048bit RSA key.  It will ask you where you would like to put these keys, in Linux the default is ~/.ssh/id_rsa and ~/.ssh/id_rsa.pub</p>
<p>We now need to copy this key to the remote server, remotemach.</p>
<pre><code>ssh-copy-id user@remotemach</code></pre>
<p>What this does is log into the remote machine and add the key to /home/user/.ssh/authorized_keys.  I am going to skip the password part for now so we don&#8217;t lock ourselves out.  If you do not have ssh-copy-id on your machine you can cat the &#8220;.pub&#8221; file and copy that to the ~/.ssh/authorized_keys on the remotemach</p>
<p>The next thing you want to do is run the following commands on the localmach.</p>
<pre><code>exec ssh-agent /bin/bash
ssh-add</code></pre>
<p>If you changed the name of the file from id_rsa you will need to specify which identity you want to add for ssh-add.  With ssh-agent running and the identity added you should now be able to login without a password.</p>
<pre><code>ssh user@remotemach</code></pre>
<p>If you were able to login without the use of a password, you can proceed to editing the /etc/ssh/sshd_config.  If you were not able to login without a password repeat the procedure and see if you are able to fix it.  I did have trouble once or twice and repeating it fixed whatever was wrong.</p>
<p>Open /etc/ssh/sshd_config and find the PasswordAuthentication configuration directive and make sure it is set to no and uncommented.</p>
<pre><code>PasswordAuthentication no</code></pre>
<p>You can now run the following command to commit the changes to the current sshd process</p>
<pre><code>sudo /etc/init.d/sshd reload</code></pre>
<p>What does all this do?</p>
<p>1. Removes the ability to login to the server with a password, you can only login to the server using a public key.</p>
<p>2. Limit the machine that you can login from.  The remotemach must have the key for the localmach in the authorized_keys file before authentication can be performed.</p>
<p>If you chose to enter a password when creating your key and you did not setup ssh-agent and ssh-add you will be prompted for a password to decrypt the key.  Do not confuse that with a standard password based login, which you are probably used to.</p>
]]></content:encoded>
			<wfw:commentRss>http://pyverted.com/sysadmin/ssh-public-key-authentication/2008/10/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
