<?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>Anchor Web Hosting Blog &#187; SSH</title>
	<atom:link href="http://www.anchor.com.au/blog/tag/ssh/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.anchor.com.au/blog</link>
	<description>A view into the Anchor Engineroom</description>
	<lastBuildDate>Wed, 08 Feb 2012 00:51:36 +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>SSH ControlMaster: The Good, The Bad, The Ugly</title>
		<link>http://www.anchor.com.au/blog/2010/02/ssh-controlmaster-the-good-the-bad-the-ugly/</link>
		<comments>http://www.anchor.com.au/blog/2010/02/ssh-controlmaster-the-good-the-bad-the-ugly/#comments</comments>
		<pubDate>Wed, 24 Feb 2010 09:55:58 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[FTW]]></category>
		<category><![CDATA[Awesome]]></category>
		<category><![CDATA[controlmaster]]></category>
		<category><![CDATA[SSH]]></category>
		<category><![CDATA[system-maintenance]]></category>
		<category><![CDATA[system-management]]></category>

		<guid isPermaLink="false">http://www.anchor.com.au/blog/?p=1451</guid>
		<description><![CDATA[Do you love SSH for the good it has done for mankind, but get annoyed by how long it takes to establish a connection over a high-latency connection? Perhaps you have a process that needs to make thousands of SSH connections, and you&#8217;d like a little extra speed from the whole thing. Either way, ControlMaster [...]]]></description>
			<content:encoded><![CDATA[<p>Do you love SSH for the good it has done for mankind, but get annoyed by how long it takes to establish a connection over a high-latency connection?  Perhaps you have a process that needs to make thousands of SSH connections, and you&#8217;d like a little extra speed from the whole thing.  Either way, <tt>ControlMaster</tt> is your new best friend.</p>
<p>The concept is very simple &#8212; rather than each new SSH connection to a particular server opening up a new TCP connection, you instead multiplex all of your SSH connections down one TCP connection.  The authentication only happens once, when the TCP connection is opened, and thereafter all your extra SSH sessions are sent down that connection.</p>
<p>If you&#8217;re SSHing between machines on the same LAN, or otherwise a short ping away, you probably wouldn&#8217;t notice the difference &#8212; the round-trip times are negligible.  However, when you&#8217;re doing transcontinental SSHing (which we do often, when we&#8217;re managing customer machines in the US), it&#8217;s a godsend.  On some trivial benchmarking I did when validating <tt>ControlMaster</tt> for our use, I found that we were saving nearly 2.5 seconds per connection &#8212; a drop from 3.3 seconds to 0.8.  Mighty convenient.</p>
<p>It&#8217;s simple to use, too.  If you just want to enable &#8220;opportunistic&#8221; multiplexing, you can do something as simple as this in your SSH config:                                                                                                                                      </p>
<pre>
Host *
ControlMaster auto
ControlPath ~/.ssh/cm_socket/%r@%h:%p
</pre>
<p>Then <tt>mkdir ~/.ssh/cm_socket</tt>, and you&#8217;re away.  Any time a connection to a remote server exists, it&#8217;ll be used as the master for any other connections.  Perusal of the <tt>ssh_config</tt>(5) manpage should give you the necessary hints to setup more restrictive configurations.  If you need to <em>disable</em> control master for a given connection (the reasons why this might be necessary will be covered shortly), you can pass <tt>-S none</tt> to <tt>ssh</tt> (or set <tt>ControlPath none</tt>).                   </p>
<hr />
<p>Whilst this basic setup is undeniable, pure, distilled awesome, there are some limitations and caveats to beware of.  The first, and most important, is that SSH session multiplexing isn&#8217;t particularly stable when you try to put a lot of data down it from a lot of connections at once.  This came to light fairly early on in my testing, when I stress-tested things by doing about 25 concurrent <tt>rsync</tt> runs all at once.  The result was a large number of rsync sessions going &#8220;aiee!&#8221; and falling over.  So, don&#8217;t do that.          </p>
<p>The second, semi-related problem, is a simple bandwidth issue.  For a given connection latency and TCP configuration, there is a hard limit to how fast you can send data, due to the time it takes to acknowledge the packets being received.  When you&#8217;re multiplexing multiple file transfers down the one TCP connection, therefore, your <em>total</em> transfer speed will be limited by this TCP speed limit.  Once again, it&#8217;s unlikely that this will cause you problems on a LAN (where round-trip delays are negligible), but in the high-latency world where connection sharing does the most good from a connection <em>setup</em> perspective, the speed limits will cause much wailing and gnashing of teeth.  So, the take home message is: if you&#8217;re doing a lot of heavy data transfer over SSH, <tt>ControlMaster</tt> probably isn&#8217;t the solution for your problems.  Instead, run multiple concurrent SSH connections, as the TCP speed limits are per-connection, so you can still fill your high-latency gigabit pipe &#8212; you just need lots of concurrent connections to do it (see also: BitTorrent).                </p>
<p>Finally, there is something of an annoyance with <tt>ControlMaster</tt>, and it&#8217;ll probably confuse you mightily when you first come across it.  Because all of your SSH sessions are multiplexed down a single TCP connection initiated by the first SSH session, that first session must stay alive until all of the other sessions are complete.  This problem will manifest itself as an apparent &#8220;hang&#8221; when you log out of the remote session that is acting as the master &#8212; instead of getting your local prompt back, SSH will just sit there.  If you Ctrl-C or otherwise kill this session, all of the other sessions you&#8217;ve got setup to that server will drop, so don&#8217;t do that.  Instead, when you logout of all the other sessions, the master will then return to the local prompt.</p>
<p>If you&#8217;re doing a high volume of SSH connections to a particular remote endpoint, consider setting up a dedicated master connection &#8212; that way it&#8217;ll always be available (and you don&#8217;t have to worry about master logout hangs).  I use a simple daemontools service, that runs <tt>ssh -MNn user@server</tt>.  Works an absolute treat.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.anchor.com.au/blog/2010/02/ssh-controlmaster-the-good-the-bad-the-ugly/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ERROR: SSH agent has too many keys</title>
		<link>http://www.anchor.com.au/blog/2009/12/error-ssh-agent-has-too-many-keys/</link>
		<comments>http://www.anchor.com.au/blog/2009/12/error-ssh-agent-has-too-many-keys/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 00:17:25 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[WTF]]></category>
		<category><![CDATA[authentication failure]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[SSH]]></category>

		<guid isPermaLink="false">http://www.anchor.com.au/blog/?p=1400</guid>
		<description><![CDATA[Unfortunately, SSH doesn&#8217;t produce this error, although it darn well should&#8230; I just had a Github customer report that they couldn&#8217;t access their repos via SSH, despite it all working properly yesterday, and &#8220;not having changed anything&#8221;. A bit of debug logging and an inspired leap of intuition on the part of another sysadmin in [...]]]></description>
			<content:encoded><![CDATA[<p>Unfortunately, SSH <em>doesn&#8217;t</em> produce this error, although it darn well should&#8230;</p>
<p>I just had a Github customer report that they couldn&#8217;t access their repos via SSH, despite it all working properly yesterday, and &#8220;not having changed anything&#8221;.  A bit of debug logging and an inspired leap of intuition on the part of another sysadmin in the office, and the answer was quickly found.</p>
<p>First off, the symptoms:</p>
<ul>
<li>Debug logging showed that the user was connecting successfully, presenting six SSH keys (none of which were the key of interest) before disconnecting;
<li>The SSH key was in the user&#8217;s SSH agent (you can verify this with a quick <tt>ssh-add -l</tt>);</li>
<li><em>There were more than six keys in the SSH agent</em></li>
</ul>
<p>This last symptom is the key point.  As an anti-brute-force measure (I assume), SSH won&#8217;t allow a user to connect and present more than <tt>MaxAuthTries</tt> credentials (whether they be passwords or keys) before being forcibly disconnected.  The default value for this parameter (if you haven&#8217;t realised already) is six.</p>
<p>Whilst this makes a lot of sense for passwords (and a lesser, but still valid, measure for keys) it does mean that you effectively have a hard limit of six keys in your agent simultaneously (at least without using SSH configs to specify a single key to present to the server).  Any more than six keys, and you run the very real risk that the key you need to give to a particular server will be number seven in your agent, and all your authentications will fail miserably.</p>
<p>Bumping the value of <tt>MaxAuthTries</tt> to a much larger value works fine for Github &#8212; password auth is disabled, and if you can manage to brute force a key you&#8217;re welcome to what you can get &#8212; but you certainly can&#8217;t rely on inflating <tt>MaxAuthTries</tt> everywhere to get you out of trouble, so: <b>keep those SSH agents lean</b>, or at least specify <tt>IdentityFile</tt> for all your servers.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.anchor.com.au/blog/2009/12/error-ssh-agent-has-too-many-keys/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Securing your codez from the wily exploit injectors</title>
		<link>http://www.anchor.com.au/blog/2009/11/securing-your-codez-from-the-wily-exploit-injectors/</link>
		<comments>http://www.anchor.com.au/blog/2009/11/securing-your-codez-from-the-wily-exploit-injectors/#comments</comments>
		<pubDate>Mon, 23 Nov 2009 12:47:49 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[FTW]]></category>
		<category><![CDATA[attack]]></category>
		<category><![CDATA[FTP]]></category>
		<category><![CDATA[password]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[SSH]]></category>
		<category><![CDATA[vulnerability]]></category>
		<category><![CDATA[website]]></category>

		<guid isPermaLink="false">http://www.anchor.com.au/blog/?p=1379</guid>
		<description><![CDATA[Remember the good old days, when Melissa and ILOVEYOU were the major virus threats, spreading via e-mail and causing all sorts of embarrassing conversations at work? Or maybe even earlier than that, when the only way you could get a virus was by engaging in risky sex? (I mean Software EXchange, of course&#8230; get your [...]]]></description>
			<content:encoded><![CDATA[<p>Remember the good old days, when Melissa and ILOVEYOU were the major virus threats, spreading via e-mail and causing all sorts of embarrassing conversations at work?  Or maybe even earlier than that, when the only way you could get a virus was by engaging in risky sex?  (I mean Software EXchange, of course&#8230; get your mind out of the gutter)</p>
<p>These days, anti-virus protection for e-mail is fairly thorough, and nobody&#8217;s really swapping floppies full of 16 colour games at recess.  Malware authors have moved on to new and more fertile ground &#8212; embedding their junk in web pages, and relying on browser exploits to gain access to computers.  Of course, with this method, you can only get infected if you actually visit a page that has an infestation, so the malware authors have two options: either entice you to visit their sites, or modify existing websites that users will visit in the course of their day &#8212; legitimate sites that people know and trust, but with a little added infection.</p>
<p>Enticing people to a whole dodgy site is usually just a matter of providing something people love to look at and sticking it in search engines.  Since the attacker has to have a stable, identifiable presence for the search engines to direct users to, that can also be used by anti-malware lists like <a href="http://stopbadware.org">stopbadware.org</a> to protect web users, so this isn&#8217;t a particularly effective means of attack, and is waning somewhat in popularity.  Far more effective is infecting a legitimate website with some form of malware.  How does it happen, though?  In our experience, there are four vectors for infection:</p>
<ol>
<li>
Brute-force password guessing, where the attacker has a botnet they control to just repeatedly try lots and lots of usernames and passwords.  They&#8217;re bound to get lucky sooner or later.
</li>
<li>
Some sort of web-based exploit, typically a vulnerability in the web application that allows the attacker to run code of their choosing; this is then either used directly to edit files, or bootstrapped into sufficient access to edit files via another method.
</li>
<li>
Password &#8220;scraping&#8221;, where the attacker gets direct access to the FTP password for your site.  This can either be some sort of malware on the workstation of the web developer (or someone else related to the management of the website) that gets the password off the local machine (in a saved password file, or via a keylogger), or else via the &#8220;lost password&#8221; functionality provided by the hosting provider.  Once the attacker has the FTP password for the site, they are free to login to the live site and make whatever changes they like.
</li>
<li>
Direct modification of the website code on the client-side computer, relying on the developer not to notice it and then upload the compromised content to the live site.  We recently had our first &#8220;confirmed&#8221; case of this (where the web developer found the malicious modifications in their local copy), and they swear blind they didn&#8217;t download the HTML from the live site (which would bring the &#8220;infection&#8221; onto the local machine from the infected live site &#8212; which we&#8217;ve seen before, and categorise under vectors 1 and/or 2).
</li>
</ol>
<p>The countermeasures required to combat all these vectors boil down to a few simple precautions.</p>
<ul>
<li>
<b>Use strong passwords</b>.  (Protects against vector 1)  Yes, they&#8217;re a pain to manage, but a weak password is just an open invitation to getting repeatedly and painfully owned.  Of course, the strongest password is a keypair, which leads us to&#8230;
</li>
<li>
<b>Don&#8217;t use FTP</b>.  (Protects against vectors 1 and 3)  The list of reasons for this is long, but for securing your website, FTP is a pain because you can <em>only</em> use passwords[<a href="#exploit_fn_1"><a name="exploit_fn_1_src">1</a></a>].  Switch to using SFTP (the file transfer component of the SSH protocol) and you can use public keys, which are, for all practical purposes, unguessable.  You should also encrypt your keys with a passphrase, which means that even if the attacker does get access to your workstation and copies the key, it&#8217;ll be useless to them &#8212; unless they keylog your passphrase, which brings us to&#8230;
</li>
<li>
<b>Keep your workstation secure</b>.  (Vectors 3 and 4)  It seems that attackers have realised that the weakest link in the website security chain is <em>still</em> the Windows desktop, and they&#8217;re increasingly hitting it as the first step in taking over websites (if you get the right workstation, you can get the credentials to hundreds or thousands of websites, because one web developer often works on many different sites).  So, on any machine you connect to webservers from, you need to be doubly, triply sure that it&#8217;s rock solid &#8212; and that&#8217;s just a matter of following all the good advice out on the web.  Antivirus, antispyware and firewall software, constantly running, well-configured, and kept up to date; keep up to date with your application patches, especially for your web browser, e-mail client, and core OS; don&#8217;t visit dodgy web sites; and so on.
</li>
<li>
<b>Protect your e-mail</b>.  (Vector 3)  If someone can get access to your e-mail, they can also get access to your website, by using the password recovery feature (or impersonating you to your hosting company).  If they delete the e-mails that are coming in before you notice them, you&#8217;ll never know what&#8217;s going on, and all the password changes and workstation security in the world won&#8217;t help you.
</li>
<li>
<b>Don&#8217;t use shared hosting</b>.  (Vectors 1 and 3).  This might seem an odd thing to say, given that we sell shared hosting, but it is a legitimate way to reduce your vulnerability.  If you use a <a href="http://www.anchor.com.au/dedicated-hosting/dedicated-servers.py">dedicated server</a> (including a <a href="http://www.anchor.com.au/vps/virtual-private-server.py">VPS</a>), you (or we) can configure it to only allow logins from certain IP addresses, rather than the entire Internet.  This means that even if an attacker does get your password (or SSH key), via brute force or sniffing it off your workstation, they can&#8217;t login from their own machine because it won&#8217;t have an authorized IP address.  On shared hosting, this configuration is impractical, because hundreds of people have legitimate access to the server, from a great many different IP addresses.
</li>
<li>
<b>Code responsibly</b>.  (Vector 2)  It is said that &#8220;PHP is great, because its ease of use means that any idiot can produce a security hole &#8212; and most of them do&#8221;.  Whilst this is a little derogatory to the many (several?  few?  one?  PLEASE?) good PHP programmers out there, it is certainly fair to say that the capabilities of many people who write dynamic code aren&#8217;t up to the challenge of writing code that is exposed to the extremely hostile conditions that are the public Internet.</p>
<p>Thus, if you are not familiar with the common security practices and problems with the language or environment that you are developing for, <em>stop right now</em> and go learn a little.  There&#8217;s plenty of good information out there on the Internet from people who have learnt the lessons the hard way.  Celebrate the benefits of literacy by learning from their mistakes rather than having to educate yourself by cleaning up an infected website.  If you feel that isn&#8217;t something you can commit to, then please, for the sake of the Internet, find someone else to write the code.
</li>
<li>
<b>Keep your web applications patched</b>.  (Vector 2)  Whilst some sites do use custom-built web applications, many sites choose to use a standard CMS or other application to manage their website.  This is great, because hopefully someone else is taking a bit of responsibility for the security of the software, but that doesn&#8217;t do you any good if you don&#8217;t <em>keep it up-to-date</em>.  Far, far too many people install a CMS once, then forget about it.  Almost all of these applications have a vulnerability at some point, and not keeping them up to date is absolutely fatal, because once a vulnerability is found in a piece of software, an attacker can typically use Google to find all of the publicly-available instances of the vulnerable software, and quickly attack them all.</p>
<p>This means that you need to keep yourself well-informed of any security updates for your off-the-shelf web applications.  Subscribe to a relevant security announcements mailing list, or ensure that your vendor sends them to you.  (If your commercial CMS vendor doesn&#8217;t have this ability, find a new CMS vendor).
</li>
</ul>
<p>Websites get compromised all the time, by a variety of methods.  You should reinforce your defences, lest you&#8217;re the next target.</p>
<hr />
<p><a href="#exploit_fn_1_src"><a name="exploit_fn_1">1</a></a>. The first person to mention Kerberos or other unused-in-practice authentication schemes in a comment gets a free laughing at.  If you think SFTP and SCP aren&#8217;t supported in widely used web development programs, try finding something that supports GSSAPI&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.anchor.com.au/blog/2009/11/securing-your-codez-from-the-wily-exploit-injectors/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>A great Windows FTP &amp; SFTP Client</title>
		<link>http://www.anchor.com.au/blog/2009/04/windows-ftp-scp-and-sftp-client/</link>
		<comments>http://www.anchor.com.au/blog/2009/04/windows-ftp-scp-and-sftp-client/#comments</comments>
		<pubDate>Tue, 21 Apr 2009 23:34:04 +0000</pubDate>
		<dc:creator>Paul De Audney</dc:creator>
				<category><![CDATA[FTW]]></category>
		<category><![CDATA[Awesome]]></category>
		<category><![CDATA[FTP]]></category>
		<category><![CDATA[SCP]]></category>
		<category><![CDATA[SSH]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.anchor.com.au/blog/?p=804</guid>
		<description><![CDATA[A question I get asked reasonably often is &#8220;Do you know any good free FTP programs?&#8221; Yes, I do. It is WinSCP. Some of the cool features are: It does what it is designed to do and does it excellently. SFTP, SCP &#38; FTP support (ditch FTP and use SFTP!) I&#8217;ve never seen it crash. [...]]]></description>
			<content:encoded><![CDATA[<p>A question I get asked reasonably often is &#8220;Do you know any good free FTP programs?&#8221; Yes, I do. It is WinSCP.</p>
<p>Some of the cool <a title="WinSCP feature listing" href="http://winscp.net/eng/docs/introduction#features" target="_blank">features</a> are:</p>
<ul>
<li>It does what it is designed to do and does it excellently. </li>
<li>SFTP, SCP &amp; FTP support (ditch FTP and use SFTP!)</li>
<li>I&#8217;ve never seen it crash.</li>
<li>Transfer resuming on broken and cancelled downloads.</li>
<li>Supports <a href="http://www.anchor.com.au/hosting/dedicated/SSH_Public_Key_Authentication">SSH keys</a>, so you do not need to remember another password.</li>
<li><a title="WinSCP scripting support" href="http://winscp.net/eng/docs/scripting" target="_blank">Scripting</a> support; schedule your own remote backups or have sane website rollout procedures!</li>
</ul>
<p>The WinSCP site describes it as &#8220;WinSCP is an open source SFTP client and FTP client for Windows. Its main function is the secure file transfer between a local and a remote computer. Beyond this, WinSCP offers basic file manager functionality. It uses Secure Shell (SSH) and supports, in addition to Secure FTP, also legacy SCP protocol.&#8221;</p>
<p>You can download it from <a title="WinSCP download page" href="http://winscp.net/eng/download.php" target="_blank">here</a> and the obligatory screen shots can be found <a title="WinSCP screenshots" href="http://winscp.net/eng/docs/screenshots" target="_blank">here</a>.</p>
<p>All of Anchor&#8217;s <a title="Shared hosting plans" href="http://www.anchor.com.au/web-hosting/website-hosting.py" target="_blank">shared hosting</a> plans support SSH &amp; SFTP connections. If you want to read more about how to use SSH, we have some wiki articles that we prepared earlier. These were targeted to cover <a title="dedicated servers" href="http://www.anchor.com.au/dedicated-hosting/dedicated-servers.py" target="_blank">dedicated</a> &amp; <a title="VPS servers" href="http://www.anchor.com.au/vps/virtual-private-server.py" target="_blank">VPS</a> servers however they are still relevant.</p>
<ul>
<li><a title="SSH Publick Key Authentication" href="http://anchor.com.au/hosting/dedicated/SSH_Public_Key_Authentication" target="_blank">SSH Public Key Authentication</a></li>
<li><a title="Securing remote access via SSH and remote server security" href="http://anchor.com.au/hosting/dedicated/Securing_Remote_Access_via_SSH_and_Server_Security" target="_blank">Securing Remote Access via SSH and Server Security</a></li>
</ul>
<p>If you manage an important site, rollout scripts can really make your web site updates pain free. I encourage anyone not using rollout scripts to have a look at the scripting capabilities of WinSCP.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.anchor.com.au/blog/2009/04/windows-ftp-scp-and-sftp-client/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

