<?xml version="1.0" encoding="utf-8"?><!DOCTYPE article  PUBLIC '-//OASIS//DTD DocBook XML V4.4//EN'  'http://www.docbook.org/xml/4.4/docbookx.dtd'><article><articleinfo><title>Howto/SSHKeys</title><revhistory><revision><revnumber>10</revnumber><date>2014-03-17 01:38:38</date><authorinitials>localhost</authorinitials><revremark>extra step for putty users needed!</revremark></revision><revision><revnumber>9</revnumber><date>2010-10-07 19:22:13</date><authorinitials>independence</authorinitials></revision><revision><revnumber>8</revnumber><date>2010-01-30 00:45:19</date><authorinitials>arthax0r</authorinitials></revision><revision><revnumber>7</revnumber><date>2010-01-28 22:35:58</date><authorinitials>arthax0r</authorinitials></revision><revision><revnumber>6</revnumber><date>2010-01-28 22:35:18</date><authorinitials>arthax0r</authorinitials></revision><revision><revnumber>5</revnumber><date>2010-01-28 22:34:45</date><authorinitials>arthax0r</authorinitials></revision><revision><revnumber>4</revnumber><date>2010-01-28 22:34:01</date><authorinitials>arthax0r</authorinitials></revision><revision><revnumber>3</revnumber><date>2010-01-28 22:20:37</date><authorinitials>arthax0r</authorinitials><revremark>How to set up ssh keys and config from command line</revremark></revision><revision><revnumber>2</revnumber><date>2010-01-28 21:23:38</date><authorinitials>78.250.209.7</authorinitials><revremark>tutorials</revremark></revision><revision><revnumber>1</revnumber><date>2010-01-28 21:04:11</date><authorinitials>78.250.209.7</authorinitials><revremark>bootsrapping the page</revremark></revision></revhistory></articleinfo><section><title>Windows</title><orderedlist numeration="arabic"><listitem><para>install pageant from <ulink url="http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html">putty</ulink> </para></listitem><listitem><para>exchanges keys </para></listitem><listitem><para>launch pageant </para></listitem><listitem><para>enter your secret passphrase </para></listitem><listitem><para>On the server convert your <ulink url="http://ipv6.blinkenshell.org/wiki/Howto/SSHKeys/wiki/PuttyGen#">PuttyGen</ulink> key to openssh format:  </para></listitem></orderedlist><screen><![CDATA[ssh-keygen -i -f puttygen_key > openssh_key]]></screen></section><section><title>Linux</title><para>SSH keys are the way, especially when used with you maintain your config file as well.  Here is the quick and dirty version. </para><para>Create your RSA keys in ~/.ssh/ </para><itemizedlist><listitem><para>$ ssh-keygen </para><itemizedlist><listitem><para>id_rsa (your private key, keep secure it is like knowing your password) </para></listitem><listitem><para>id_rsa.pub (your public key, you copy this places you want to recognize you [sorta]) </para></listitem></itemizedlist></listitem></itemizedlist><para>This right here is the easy way to do something I did by hand for a long time: </para><screen><![CDATA[ssh-copy-id username@ssh.blinkenshell.org]]></screen><para>This appends ~/.ssh/id_rsa.pub to the ~/.ssh/authorized_keys file of the remote host.  It also removes group writability on ~/.ssh and ~/.ssh/authorized_keys in case <ulink url="http://ipv6.blinkenshell.org/wiki/Howto/SSHKeys/wiki/StrictModes#">StrictModes</ulink> is set on the server. <emphasis>The negative aspect to this approach is that you cannot specify a port, so if the service is running on a non-standard port, such as the case with Blinkenshell, you need to add the host to your config file first.</emphasis> The manual way to do it is as follows: </para><screen><![CDATA[scp -P 2222 ~/.ssh/id_rsa.pub username@ssh.blinkenshell.org:~/.ssh/authorized_keys]]></screen><para>Which seems just as easy, but is not, if you already have an authorized key file and want to append to it rather than overwrite it.  Plus, ssh-copy-id will create ~/.ssh if it does not already, which it won't, if you have not ssh'd out from that account on that box.  In which case it would be something like this: </para><screen><![CDATA[ssh -p 2222 username@ssh.blinkenshell.org mkdir .ssh
scp -P 2222 ~/.ssh/id_rsa.pub username@ssh.blinkenshell.org :
ssh -p 2222 username@ssh.blinkenshell.org cat id_rsa.pub >> .ssh/authorized_keys && rm id_rsa.pub && chmod -R 740 .ssh]]></screen><para><emphasis role="strong">Example Blinkenshell ~/.ssh/config Entry</emphasis> </para><para>This goes in ~/.ssh/ on the machine you are ssh'ing <emphasis>out</emphasis> of: </para><screen><![CDATA[Host blink
Port 2222
User arthax0r
HostName ssh.blinkenshell.org]]></screen><para>With blank lines between entries for other hosts, and you can leave the port line out if it is on 22 as is standard.  Also, you can leave out the user name is the same on both hosts. </para><para>Now that you have a config file, it's as easy as this: </para><screen><![CDATA[ssh-copy-id blink
ssh blink]]></screen><itemizedlist><listitem override="none"><para>Voila!  No password prompt or long command line bs for ssh/scp, cuz you can also do this: </para></listitem></itemizedlist><screen><![CDATA[scp -r MySweetDirectoryFullOfGoodies blink:~/wherever/you/want]]></screen><para>Enjoy your knew ssh pimp cane! </para><itemizedlist><listitem override="none"><para>-ah'2010 </para></listitem></itemizedlist></section><section><title>Potential tutorials</title><itemizedlist><listitem><para><ulink url="http://www.howtoforge.com/ssh_key_based_logins_putty"/> </para></listitem><listitem><para><ulink url="http://www.vpac.org/node/273"/> </para></listitem></itemizedlist><!--rule (<hr>) is not applicable to DocBook--><para> <ulink url="http://ipv6.blinkenshell.org/wiki/Howto/SSHKeys/wiki/CategoryHowto#">CategoryHowto</ulink> </para></section></article>