    <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:content="http://purl.org/rss/1.0/modules/content/">
     <channel>
        <title>ACCU  :: One SSH Key Per Machine!</title>
        <link>https://members.accu.org/index.php/journals/2554</link>
        <description>Professionalism in Programming</description>
        <dc:language>en-us</dc:language> 
        <dc:creator>Administrator</dc:creator> 
        <admin:generatorAgent rdf:resource="http://www.xaraya.org" /> 
        <admin:errorReportsTo rdf:resource="mailto:webeditor@accu.org" />
       <sy:updatePeriod>hourly</sy:updatePeriod>
       <sy:updateFrequency>1</sy:updateFrequency>
       <docs>http://backend.userland.com/rss</docs>


        <h2>Journal Articles</h2>


<div class="xar-mod-head"><span class="xar-mod-title">CVu Journal Vol 30, #4 - September 2018 + Internet Topics</span></div>

<table border="0" cellpadding="1" cellspacing="0">
    <tbody>
    <tr>
        <td valign="top">
            Browse in :
       </td>
       <td valign="top">

                                            <a href="https://members.accu.org/index.php/journals/">All</a>

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c76/">Journals</a>

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c77/">CVu</a>

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c390/">304</a>
                    (10)
<br />

                                            <a href="https://members.accu.org/index.php/journals/">All</a>

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c13/">Topics</a>

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c69/">Internet</a>
                    (35)
<br />

                                            <a href="https://members.accu.org/index.php/journals/c390-69/">Any of these categories</a>

                    -                        <a href="https://members.accu.org/index.php/journals/c390+69/">All of these categories</a>
<br />
</td>
   </tr>
   </tbody>
</table>




<div class="xar-error">
   <p>
 <strong>Note:</strong> when you create a new publication type,
the articles module will automatically use the templates
<em>user-display-[publicationtype].xt</em>
and <em>user-summary-[publicationtype].xt</em>.
If those templates do not exist when you try to preview or display a new article,
you'll get this warning :-)  Please place your own templates in themes/<em>yourtheme</em>/modules/articles . The templates will get the extension .xt there. </p>
</div>
<div class="xar-norm xar-standard-box-padding">
   <h1><strong>Title:</strong>&nbsp;One SSH Key Per Machine!</h1>
<p><strong>Author:</strong>&nbsp;Bob Schmidt</p>
<p>
<strong>Date:</strong> 05 September 2018 18:32:49 +01:00 or Wed, 05 September 2018 18:32:49 +01:00</p>
<p><strong>Summary:</strong>&nbsp;Silas S. Brown has some advice on configuring secure connections.</p>
<p><strong>Body:</strong>&nbsp;<p>I recently had a small nightmare when my private SSH key was compromised. I had left it on a system I trusted, but due to a mistake made by (apparently) a newly-employed system administrator, the entire contents of my home directory on that system, including the private SSH key, was made available for public download for a few hours and they didnâ€™t have logs to show whether or not it had been downloaded. So I had to quickly contact every server on which Iâ€™d ever placed my public SSH key and either change it myself or ask them to revoke it (I had to ask them in cases where the server was offline or otherwise unreachable but I was concerned it might be put back online later).</p>

<p>I now have a different private SSH key on each system. Instead of thinking of the private key as â€˜my keyâ€™ that identifies me as an individual, I now think of it as identifying the system (well, my account on the system) that Iâ€™m using. I may have to add multiple public keys to each <span class="filename">.ssh/authorized_keys</span> file on the servers I have access to, but I have much more fine-grained control over which of my clients can access which servers, which should hopefully reduce the hassle next time we find a breach (if server X trusts client Y but not client Z, then I donâ€™t have to bother updating server X when Iâ€™m told client Z was compromised).</p>

<p>My <span class="filename">.ssh/authorized_keys</span> files now look like:</p>

<pre class="programlisting">
  ssh-rsa long_key_here client1
  ssh-rsa long_key_here client2</pre>
  
<p>where <code>client1</code>, <code>client2</code> etc can be any strings I like (the third field of these files is ignored by sshd), so I simply use them to name the machines on which the corresponding private keys are stored. Each key is, of course, generated by running the <code>ssh-keygen</code> command on the corresponding client (thereâ€™s no point running it elsewhere), which creates <span class="filename">.ssh/id_rsa</span> (the private key) and <span class="filename">.ssh/id_rsa.pub</span> (the public key) â€“ I then edit the public key file and make sure the label is what I want it to be, before copying it to the <span class="filename">.ssh/authorized_keys</span> of the servers I use and/or uploading it to GitHub, GitLab and/or Bitbucket. (I did once have a problem with Bitbucket: I had both a personal account and a work account, and it wouldnâ€™t let me use the same SSH key for both, so if I wanted to access both from the same machine then I had to generate two keys on that machine and look up how to use git with ssh-agent to select an alternate key, but hopefully thatâ€™s a rare situation.)</p>

<p>Many (but not all) SSH servers also allow you to put <code>from=&quot;IP&quot;</code> before the ssh-rsa column, where IP is a single IP address or a list of IP addresses and/or subnets (e.g. <code>from=&quot;192.168.0.0/16,1.2.3.4&quot; ssh-rsa</code> ...) to specify from where the client is expected to connect. This doesnâ€™t provide very much additional security, since anyone who fully compromises a client is likely to use it in-place with no change of IP address, but it may at least protect against the lesser failure mode of an attacker obtaining a copy of a private key but without actually obtaining control of the client on which it is stored. So if a particular client has a fixed IP address, or is within a fixed IP network block, it may be worth considering adding <code>from=</code> specifiers, although you will of course need to change these if the client ever does change its IP.</p>

<p>Iâ€™m also an avid user of the <span class="filename">.ssh/config</span> file on clients to abbreviate hostnames and do other tricks. For example:</p>

<pre class="programlisting">
  TCPKeepAlive yes
  ServerAliveInterval 200
  Compression yes
  CompressionLevel 9
  
  Host ds linux.ds.cam.ac.uk pwf
   HostName linux.ds.cam.ac.uk
   User ssb22
   ControlMaster auto
   ControlPath /tmp/.dspath</pre>
   
<p>The first four options are useful over slow or unreliable links. The <code>Host</code> option lets me give the server several names (in this case including the old name it used to have, in case I ever accidentally type that one) and maps it to the real <code>HostName</code>. The <code>User</code> option makes sure I log in as the correct user even if my username on the local system is different (although I usually try to get the same username if I can). The <code>ControlMaster</code> and <code>ControlPath</code> options let me pass additional sessions through the same connection, which is useful if the server keeps your home directory on a Windows file share or something, as this often results in it requiring a password login rather than a public key login: at least <code>ControlPath</code> lets you avoid typing the password for any additional shells you want to open.</p>

<p>Other good options include <code>Port</code>, if the server is running on a non-standard port to reduce the amount of clutter in its logs from probes, and <code>ProxyCommand</code>, which can be set to run a â€˜port-knockingâ€™ script to ask the server to open its port before performing an <code>nc</code> command to it. You need to write the latter as:</p>

<pre class="programlisting">
  ProxyCommand /bin/bash -c 'port-knock &gt;/dev/null  2&gt;/dev/null &amp;&amp; /usr/bin/nc %h %p'</pre>
  
<p>where <code>port-knock</code> is whatever command you use to do the â€˜port knockingâ€™ (or for example a curl command to run a CGI script that opens the port).</p>

<p class="bio"><span class="author"><b>Silas S. Brown</b></span>  Silas is a partially-sighted Computer Science post-doc in Cambridge who currently works in part-time assistant tuition. He has been an ACCU member since 1994 and can be contacted at ssb22@cam.ac.uk</p>
</p>
<p><strong>Notes:</strong>&nbsp;</p>
<p><em>More fields may be available via dynamicdata ..</em></p>
</div>
</channel>
</rss>
