<?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 and Open Source Blog &#187; ssh</title>
	<atom:link href="http://linewbie.com/tag/ssh/feed" rel="self" type="application/rss+xml" />
	<link>http://linewbie.com</link>
	<description>News, Reviews, Thoughts and Trends in Linux and Open Source World.</description>
	<lastBuildDate>Mon, 23 Jan 2012 18:49:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Best Practices when using SSH</title>
		<link>http://linewbie.com/2008/01/best-practices-when-using-ssh.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=best-practices-when-using-ssh</link>
		<comments>http://linewbie.com/2008/01/best-practices-when-using-ssh.html#comments</comments>
		<pubDate>Tue, 29 Jan 2008 05:58:36 +0000</pubDate>
		<dc:creator>Linewbie.com</dc:creator>
				<category><![CDATA[guides]]></category>
		<category><![CDATA[tutorials]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://www.linewbie.com/2008/01/best-practices-when-using-ssh.html</guid>
		<description><![CDATA[Author: Ryan M. Original Website: linuxsecurity.com Introduction Are you using SSH in the best way possible? Have you configured it to be as limited and secure as possible? The goal of this document is to kick in the new year &#8230; <a href="http://linewbie.com/2008/01/best-practices-when-using-ssh.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Author: Ryan M.<br />
Original Website: <a href="http://www.linuxsecurity.com/">linuxsecurity.com</a></p>
<h3>Introduction</h3>
<p>Are you using SSH in the best way possible? Have you configured it to be as limited and secure as possible? The goal of this document is to kick in the new year with some best practices for SSH: why you should use them, how to set them up, and how to verify that they are in place.</p>
<p>All of the examples below assume that you are using EnGarde Secure Linux but any modern Linux distribution will do just fine since, as far as I know, everybody ships OpenSSH.</p>
<h3>SSHv2 vs. SSHv1</h3>
<p>There are numerous benefits to using the latest version of the SSH protocol, version 2, over it&#8217;s older counterpart, version 1 and I&#8217;m not going into a lot of details on those benefits here &#8211; if you&#8217;re interested, see the URL in the reference below or Google around. That being said if you don&#8217;t have an explicit reason to use the older version 1, you should always be using version 2.</p>
<p><span id="more-455"></span></p>
<p>To use SSHv2 by default but permit SSHv1, locate the &#8220;Protocol&#8221; line in your sshd_config file and change it to:</p>
<pre>Protocol 2,1</pre>
<p>When doing 2,1 please note that the protocol selection is left up to the client. Most clients will default to v2 and &#8220;fall back&#8221; to v1, while legacy clients may continue to use v1. To force everybody to use SSHv2, change it to:</p>
<pre>Protocol 2</pre>
<p>When you make this change don&#8217;t forget to generate the appropriate HostKey&#8217;s as well!  SSHv2 requires the following keys:</p>
<pre># HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key</pre>
<p>While SSHv1 requires:</p>
<pre># HostKey for protocol version 1
HostKey /etc/ssh/ssh_host_key</pre>
<p>Once your changes are made, restart the SSH daemon:</p>
<p class="command"># /etc/init.d/sshd restart</p>
<p class="system">[ SUCCESSFUL ] Secure Shell Daemon<br />
[ SUCCESSFUL ] Secure Shell Daemon</p>
<p>From another machine, try SSH&#8217;ing in. You can use the <span class="system">-v option </span>to see which protocol is being used, and the &#8216;-oProtocol=&#8217; option to force one or the other &#8211; for example, &#8220;ssh -v -oProtocol=2 <host>&#8221; would force protocol version 2.</host></p>
<h3>Binding to a Specific Address or Non-Standard Port</h3>
<p>If you&#8217;re running SSH on an internal, firewalled, workstation then you can probably skip this section, but if you&#8217;re running SSH on a firewall or on a machine with two network interfaces, this section is for you.</p>
<p>Out of the box OpenSSH will bind to every available network address; while convenient and suitable for most installations, this is far from optimal. If your machine has two or more interfaces then the odds are that one is &#8220;trusted&#8221; and the other is &#8220;untrusted.&#8221; If this is the case, and you don&#8217;t need nor want SSH access coming in on the untrusted interface, then you should configure OpenSSH to listen on a specific interface.</p>
<p>To have OpenSSH only bind to your internal interface, 192.168.0.1 in the example below, locate the following line in your sshd_config file:</p>
<pre>ListenAddress 0.0.0.0</pre>
<p>and change the 0.0.0.0 to 192.168.0.1:</p>
<pre>ListenAddress 192.168.0.1</pre>
<p>To verify that this change took, restart OpenSSH and look at netstat:</p>
<p class="command"># /etc/init.d/sshd restart</p>
<p class="system">[ SUCCESSFUL ] Secure Shell Daemon<br />
[ SUCCESSFUL ] Secure Shell Daemon</p>
<p class="command"># netstat -anp | grep sshd</p>
<p class="system">tcp        0      0 192.168.0.1:22          0.0.0.0:*               LISTEN      7868/sshd</p>
<p><strong>As you can see, the sshd daemon is now only listening on 192.168.0.1.</strong> SSH requests coming in <strong>any other interface</strong> will be ignored.</p>
<p>Similarly, you may want to change the port that the SSH daemon binds to. Sometimes there is a functional need for this (ie, your employer blocks outbound 22/tcp) but there is also security-through-obscurity value in this as well. While not providing any real security benefit against a determined attacker, moving the SSH daemon off of port 22 protects you against automated attacks which assume that the daemon is running on port 22.</p>
<p>To have OpenSSH bind to a port other than port 22, 31337 in the example below, locate the following line in your sshd_config file:</p>
<pre>Port 22</pre>
<p>and change the 22 to 31337:</p>
<pre>Port 31337</pre>
<p>To verify that this change took, restart OpenSSH and, again, look at netstat:</p>
<p class="command"># netstat -anp | grep sshd</p>
<p class="system">tcp        0      0 192.168.0.1:31337       0.0.0.0:*               LISTEN      330/sshd</p>
<p>Finally, to SSH into a host whose SSH daemon is listening on a non-standard port, use the -p option:</p>
<p class="command">ssh -p 31337 user@192.168.0.1</p>
<h3>Using TCP Wrappers</h3>
<p>TCP Wrappers are used to limit access to TCP services on your machine. If you haven&#8217;t heard of TCP Wrappers you&#8217;ve probably heard of /etc/hosts.allow and /etc/hosts.deny: these are the two configuration files for TCP Wrappers. In the context of SSH, TCP Wrappers allow you to decide what specific addresses or networks have access to the SSH service.</p>
<p>To use TCP Wrappers with SSH you need to make sure that OpenSSH was built with the -with-tcp-wrappers. This is the case on any modern distribution.</p>
<p>As I indicated earlier, TCP Wrappers are configured by editing the /etc/hosts.deny and /etc/hosts.allow files. Typically you tell hosts.deny to deny everything, then add entries to hosts.allow to permit specific hosts access to specific services.</p>
<p>An example:</p>
<pre>#
# hosts.deny    This file describes the names of the hosts which are
#               *not* allowed to use the local INET services, as decided
#               by the '/usr/sbin/tcpd' server.
#
ALL: ALL
#
# hosts.allow   This file describes the names of the hosts which are
#               allowed to use the local INET services, as decided
#               by the '/usr/sbin/tcpd' server.
#
sshd: 207.46.236. 198.133.219.25</pre>
<p>In the example above, access to SSH is limited to the network 207.46.236.0/24 and the address 198.133.219.25. Requests to any other service from any other address are denied by the &#8220;ALL: ALL&#8221; in hosts.deny. If you try to SSH into a machine and TCP Wrappers denies your access, you&#8217;ll see something like this:</p>
<p class="system">ssh_exchange_identification: Connection closed by remote host</p>
<p>This simple configuration change significantly hardens your installation since, with it in place, packets from hostile clients are dropped very early in the TCP session &#8212; and before they can do any real damage to a potentially vulnerable daemon.</p>
<h3>Public Key Authentication</h3>
<p>The last item I will cover is public key authentication. One of the best things you can do to tighten the security of your SSH installation is to disable password authentication and to use public key authentication instead. Password authentication is suboptimal for many reasons, but mostly because people choose bad passwords and attackers routinely try to brute-force passwords. If the systems administrator has chosen a bad password and he&#8217;s permitting root logins&#8230; game over.</p>
<p>Public key authentication is no silver bullet &#8211; similarly, people generate passphrase-less keys or leave ssh-agents running when they shouldn&#8217;t &#8211; but, in my opinion, it&#8217;s a much better bet.</p>
<p>Just about every distribution ships with public key authentication enabled, but begin by making sure it is:</p>
<pre>RSAAuthentication yes
PubkeyAuthentication yes</pre>
<p>Both of these options default to &#8220;yes&#8221; and the &#8220;RSAAuthentication&#8221; option is for SSHv1 and the &#8220;PubkeyAuthentication&#8221; option is for SSHv2. If you plan on using this authentication method exclusively, while you&#8217;re there, you may want to disable password authentication:</p>
<pre>PasswordAuthentication no</pre>
<p>Before you proceed, make sure you have a terminal open on your target machine. Once you restart the SSH daemon you will no longer be able to log in without a key&#8230; which we haven&#8217;t generated yet!</p>
<p>Once you&#8217;re sure, restart the SSH daemon:</p>
<p class="command"># /etc/init.d/sshd restart</p>
<p class="system">[ SUCCESSFUL ] Secure Shell Daemon<br />
[ SUCCESSFUL ] Secure Shell Daemon</p>
<p>Now, from your desktop, try to SSH in to your target machine:</p>
<p class="command">$ ssh rwm@brainy</p>
<p class="system">Permission denied (publickey,keyboard-interactive).</p>
<p><strong>We&#8217;re locked out!</strong>  This is a <strong>good </strong>thing.  The next step, on your desktop, is to generate a key:</p>
<p class="command">$ ssh-keygen -t dsa -C &#8220;Ryan&#8217;s SSHv2 DSA Key (Jan 2008)&#8221;</p>
<p class="system">Generating public/private dsa key pair.<br />
Enter file in which to save the key (/home/rwm/.ssh/id_dsa):<br />
Enter passphrase (empty for no passphrase): **********<br />
Enter same passphrase again: **********<br />
Your identification has been saved in /home/rwm/.ssh/id_dsa.<br />
Your public key has been saved in /home/rwm/.ssh/id_dsa.pub.<br />
The key fingerprint is:<br />
98:4d:50:ba:ee:8b:79:be:b3:36:75:8a:c2:4a:44:4b Ryan&#8217;s SSHv2 DSA Key (Jan 2008)</p>
<h4>A few notes on this:</h4>
<ul>
<li>You can generate a DSA (-t dsa), RSA (-t rsa), or SSHv1 (-t rsa1) key.  In the example above I&#8217;m using dsa.</li>
<li>I like to put the date I generated the key in the comment (-C) field, that way I can change it out every so often.</li>
<li>You&#8217;re entering a passphrase, not a password. Use a long string with spaces and punctuation. The longer and more complicated the better!</li>
</ul>
<p>The command you just ran generated two files &#8211; id_dsa, your private key and id_dsa.pub, your public key. It is critical that you keep your private key private, but you can distribute your public key to any machines you would like to access.</p>
<p>Now that you have generated your keys we need to get the public key into the ~/.ssh/authorized_keys file on the target machine. The best way to do this is to copy-and-paste it &#8211; begin by concatenating the public key file:</p>
<p class="command">$ cat .ssh/id_dsa.pub</p>
<p class="system">ssh-dss AAAAB3NzaC1kc3MAAACBAL7p6bsg5kK4ES9BWLPCNABl20iQQB3R0ymaPMHK&#8230;<br />
&#8230; ds= Ryan&#8217;s SSHv2 DSA Key (Jan 2008)</p>
<p>This is a very long string. Make sure you copy <u>all of it </u>and that you do NOT copy the newline character at the end. In other words, copy from the &#8220;ssh&#8221; to the &#8220;2008)&#8221;, but not past that.</p>
<p>The next step is to append this key to the end of the ~/.ssh/authorized_keys file on your target machine. Remember that terminal I told you to keep open a few steps ago? Type the following command into it, pasting the key you&#8217;ve just copied into the area noted KEY:</p>
<p class="command">echo &#8220;KEY&#8221;  &gt;&gt; ~/.ssh/authorized_keys</p>
<p>For example:</p>
<p class="command">echo &#8220;ssh-dss AAAA5kS9BWLPCN&#8230;s= Ryan&#8217;s SSHv2 DSA Key (Jan 2008)&#8221;  &gt;&gt; ~/.ssh/authorized_keys</p>
<p>Now, try to SSH in again. If you did this procedure correctly then instead of being denied access, you&#8217;ll be prompted for your passphrase:</p>
<p class="command">$ ssh rwm@brainy</p>
<p class="system">Enter passphrase for key &#8216;/home/rwm/.ssh/id_dsa&#8217;:<br />
Last login: Thu Jan 10 14:37:14 2008 from papa.engardelinux.org<br />
[rwm@brainy ~]$</p>
<p>Viola!  You&#8217;re now logged in using public key authentication instead of password authentication.</p>
<h3>In Summary&#8230;</h3>
<p>SSH is a wonderful tool and is every systems administrators second best friend (Perl, of course, being the first <img src='http://linewbie.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . It allows you to read your email from anywhere, provided you still use a terminal-based mail reader. It allows you to tunnel an xterm or X11 application from your home server to your desktop at work. It provides you a far superior alternative to FTP in SFTP and SCP.</p>
<p>SSH is great but just like any tool, it&#8217;s only as good as you use it. I hope that you found value in some of my best practices and if you have any of your own, leave them in the comments!</p>
<p>Before I go, here are some additional resources on SSH:</p>
<ul>
<li> <a href="http://www.openssh.com/" target="_blank"> The OpenSSH Project </a></li>
<li> <a href="http://www.snailbook.com/" target="_blank"> SSH, The Secure Shell: The Definitive Guide </a></li>
<li> <a href="http://www.pcs.cnu.edu/%7Embland/ssh_intro/" target="_blank"> Introduction to SSH Versions 1 and 2 </a></li>
<li> <a href="http://www.linuxsecurity.com/content/view/131846/171/" target="_blank"> Knock, Knock, Knockin&#8217; on EnGarde&#8217;s Door (with FWKNOP) </a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://linewbie.com/2008/01/best-practices-when-using-ssh.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Top 10 Tools I Canâ€™t Live Without</title>
		<link>http://linewbie.com/2007/10/top-10-tools-i-can%e2%80%99t-live-without.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=top-10-tools-i-can%25e2%2580%2599t-live-without</link>
		<comments>http://linewbie.com/2007/10/top-10-tools-i-can%e2%80%99t-live-without.html#comments</comments>
		<pubDate>Wed, 10 Oct 2007 15:18:31 +0000</pubDate>
		<dc:creator>Linewbie.com</dc:creator>
				<category><![CDATA[general topics]]></category>
		<category><![CDATA[review/preview/tests]]></category>
		<category><![CDATA[blogbridge]]></category>
		<category><![CDATA[fastmail]]></category>
		<category><![CDATA[fire fox]]></category>
		<category><![CDATA[flickr]]></category>
		<category><![CDATA[photoshop]]></category>
		<category><![CDATA[scribefire]]></category>
		<category><![CDATA[skype]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[top 10 tools]]></category>
		<category><![CDATA[webdav]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.linewbie.com/2007/10/top-10-tools-i-can%e2%80%99t-live-without.html</guid>
		<description><![CDATA[We all have our own unique ways of working. A large part of any persons individual productivity is the tools they use. Here is my top 10 Must Have Tools (and why), please add yours in the comments! Firefox &#8211; &#8230; <a href="http://linewbie.com/2007/10/top-10-tools-i-can%e2%80%99t-live-without.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>We all have our own unique ways of working. A large part of any persons individual productivity is the tools they use. Here is my top 10 Must Have Tools (and why), please add yours in the comments!</p>
<ol>
<li><a href="http://getfirefox.com/"><img border="0" align="left" width="88" src="http://www.linewbie.com/upload/sfx-images.mozilla.org/affiliates/Buttons/firefox2/firefox-spread-btn-1.png" alt="Firefox" height="31" title="Firefox" /><font color="#c01328">Firefox</font></a> &#8211; I started out with Mosaic, then Netscape. For years I was an Internet Explorer user but then Microsoft dropped the ball and the Mozilla team ran with it. Firefox is stable, extensible and fast enough. One of the killer features that made me defect was the tabbed browsing. Of course most web browsers now have that feature. <a href="http://www.lifehack.org/articles/productivity/top-10-greasemonkey-scripts-to-improve-your-productivity.html"><font color="#c01328">Firefox plus Greasemonkey</font></a> takes an already rockinâ€™ browser into a world of its own.</li>
<li><a href="http://scribefire.com/"><font color="#c01328">ScribeFire</font></a> &#8211; One of my main jobs is writing on blogs. This means lots of linking, bookmarking, making notes and of course the actual writing. I would say using Scribefire I can do it all in half the time. Scribefire is a Firefox plugin that provides blogging tools including a centralized word-like text editing interface.</li>
<li><a href="http://skype.com/"><img border="0" align="left" width="105" src="http://www.linewbie.com/upload/sfx-images.mozilla.org/i_preairlift/logos/skype_logo.png" alt="Skype" height="47" title="Skype" /><font color="#c01328">Skype</font></a> &#8211; Many of my calls are long distance as it is rare for me to have a client in the same country as I live. Skype makes these calls free or much cheaper and allows me to roam around and not be tied to a land-line. With my trusty headset I might look like a geek but I can hear and be heard right across the globe.</li>
<li><a href="http://fastmail.fm/"><font color="#c01328">Fastmail</font></a> &#8211; While many people swear by the free Google GMail my web email service of choice is the paid service at Fastmail. The main advantage is as well as having a web client you can also access your email using imap, allowing me to sync my desktop client and see in a web browser exactly the same email store.</li>
<li><a href="http://en.wikipedia.org/wiki/WebDAV"><font color="#c01328">WebDav</font></a> &#8211; Talking of web based storage, a fantastic way to get your files on the go is WebDav. Drag and drop your files and folders just like you were working locally. Check out your web host to see if this is an option.</li>
<li><a href="http://www.openssh.com/"><font color="#c01328">SSH</font></a> &#8211; This is an extremely nerdy choice but it has been a life saver in the past. SSH allows you a secure command line login to your remote server. On Windows of course you can use Remote Desktop, and other platforms will have VNC, but when the proverbial hits the fan you can rely on SSH and old school commands to get the job done.</li>
<li><a href="http://wordpress.org/"><img border="0" align="left" width="250" src="http://www.linewbie.com/upload/sfx-images.mozilla.org/convert-pdf-to-excel/wp-admin/images/wordpress-logo.png" height="68" /><font color="#c01328">WordPress</font></a> &#8211; I love WordPress, I wouldnâ€™t recommend any other blogging platform for the individual or small team. But WordPress can be so much more than a blog! Use it for publishing your corporate website, internal project documentation, team collaboration, making notes, bookmarking, even as a discussion platform.</li>
<li><a href="http://adobe.com/photoshop"><font color="#c01328">Photoshop</font></a> &#8211; There are cheaper options. I will probably never use even half the features. Photoshop still rules. There is little it canâ€™t do, and if you wander into any design studio you can be sure there will be at least one machine running it. Productivity means being able to do what you need to do well and fast. Once you have learned it, Photoshop makes that happen for working with images.</li>
<li><a href="http://blogbridge.com/"><font color="#c01328">BlogBridge</font></a> &#8211; I need my RSS feeds and I need them with me. While many people can argue in favor of their fave web clients I keep returning to BlogBridge happily time after time. It is a Java based desktop application so works wherever Java works and stores your feeds offline so you can read on the train, in the air or bus home.</li>
<li><a href="http://flickr.com/"><img border="0" align="left" width="98" src="http://www.linewbie.com/upload/sfx-images.mozilla.org/www.flickr.com/images/flickr_logo_gamma.gif.v1.5.10" height="26" /><font color="#c01328">Flickr</font></a> &#8211; Flickr for me is more than just an online photo gallery, it is a photography archive, a community and a source of royalty-free images (Creative Commons Licensed pics). Itâ€™s useful, fun and a constant source of education.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://linewbie.com/2007/10/top-10-tools-i-can%e2%80%99t-live-without.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

