{"id":16311,"date":"2020-02-26T13:19:04","date_gmt":"2020-02-26T13:19:04","guid":{"rendered":"https:\/\/www.bartbusschots.ie\/s\/?p=16311"},"modified":"2020-02-26T13:28:34","modified_gmt":"2020-02-26T13:28:34","slug":"generating-ssh-keys-on-windows-with-puttygen","status":"publish","type":"post","link":"https:\/\/www.bartbusschots.ie\/s\/2020\/02\/26\/generating-ssh-keys-on-windows-with-puttygen\/","title":{"rendered":"Generating SSH Keys on Windows with PuTTYgen"},"content":{"rendered":"<p>In <a href=\"https:\/\/www.bartbusschots.ie\/s\/2015\/03\/29\/taming-the-terminal-part-30-of-n-sshing-more-securely\/\" target=\"_blank\" rel=\"noopener noreferrer\">instalment 30 of the Taming the Terminal series<\/a> I showed how SSH keys can be used to more securely and conveniently connect to servers. The instructions in that instalment are for Linux-like OSes (including MacOS) where the standard OpenSSH tools are available.<\/p>\n<p>Windows doesn&#8217;t ship with OpenSSH (or indeed any SSH implementation), so Windows users who want to SSH need to install some kind of additional software. With Windows 10 there is the obvious option of <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/wsl\/install-win10\" rel=\"noopener noreferrer\" target=\"_blank\">installing the Windows Subsystem for Linux<\/a>, but people may prefer a GUI experience. The obvious choice for Windows users is the venerable free and open source <a href=\"https:\/\/www.putty.org\" rel=\"noopener noreferrer\" target=\"_blank\">PuTTY<\/a> suite of tools.<\/p>\n<p>The PuTTY SSH client itself is easy to use, and if you install the full suite of apps via the MSI installer (available on <a href=\"https:\/\/www.chiark.greenend.org.uk\/~sgtatham\/putty\/latest.html\" rel=\"noopener noreferrer\" target=\"_blank\">their download page<\/a>) you&#8217;ll also get a GUI for generating SSH keys named PuTTYgen.<\/p>\n<p><!--more--><\/p>\n<p>To play along you&#8217;ll need an SSH server and account to connect to, and PuTTY and PuTTYgen installed on a Windows PC.<\/p>\n<p>As explained in more detail in the Taming the Terminal instalment, SSH keys come in pairs. One half of the pair should never be shared and be protected, like you would a real-world key. This is referred to as the <em>Private Key<\/em>. The other half of the pair can be freely shared without any security implications. In fact, not only can it be shared, in order to use your key-pair it must be shared! This is referred to as the <em>Public Key<\/em>.<\/p>\n<h2>Generate an SSH Key Pair<\/h2>\n<p>Launch the PuTTYgen app and click the Generate button:<\/p>\n<p style=\"text-align: center\"><img decoding=\"async\" src=\"https:\/\/www.bartbusschots.ie\/s\/wp-content\/uploads\/2020\/02\/Screenshot-2020-02-26-at-12.01.07.png\" alt=\"Screenshot showing PuTTYgen key-pair generation\" width=\"480\" class=\"alignnone size-full wp-image-16313\" style=\"border: 1px solid black\" srcset=\"https:\/\/www.bartbusschots.ie\/s\/wp-content\/uploads\/2020\/02\/Screenshot-2020-02-26-at-12.01.07.png 998w, https:\/\/www.bartbusschots.ie\/s\/wp-content\/uploads\/2020\/02\/Screenshot-2020-02-26-at-12.01.07-300x298.png 300w, https:\/\/www.bartbusschots.ie\/s\/wp-content\/uploads\/2020\/02\/Screenshot-2020-02-26-at-12.01.07-150x150.png 150w, https:\/\/www.bartbusschots.ie\/s\/wp-content\/uploads\/2020\/02\/Screenshot-2020-02-26-at-12.01.07-768x763.png 768w\" sizes=\"(max-width: 998px) 100vw, 998px\" \/><\/p>\n<p>Follow the instructions and create some randomness by moving your mouse over the blank area in the middle of the app&#8217;s UI.<\/p>\n<p>Once the key is generated the UI will update and you&#8217;ll be presented with three editable text boxes in what was the blank area in the UI.<\/p>\n<p>The first editable text box allows you to give you key a human-friendly label. Type a description of the key that will be meaningful to you into that box, maybe something like <em>&#8220;Bart B Windows SSH Key&#8221;<\/em>.<\/p>\n<p>Unless you will be using the key in some kind of script, you should set a password on it. Don&#8217;t forget this password \u00e2\u20ac\u201d without it the key-pair will be useless!<\/p>\n<p style=\"text-align: center\"><img decoding=\"async\" src=\"https:\/\/www.bartbusschots.ie\/s\/wp-content\/uploads\/2020\/02\/Screenshot-2020-02-26-at-12.05.32.png\" alt=\"Screenshot showing PuTTYgen key-pair configuration\" width=\"480\" class=\"alignnone size-full wp-image-16314\" style=\"border: 1px solid black\" srcset=\"https:\/\/www.bartbusschots.ie\/s\/wp-content\/uploads\/2020\/02\/Screenshot-2020-02-26-at-12.05.32.png 1004w, https:\/\/www.bartbusschots.ie\/s\/wp-content\/uploads\/2020\/02\/Screenshot-2020-02-26-at-12.05.32-300x294.png 300w, https:\/\/www.bartbusschots.ie\/s\/wp-content\/uploads\/2020\/02\/Screenshot-2020-02-26-at-12.05.32-768x753.png 768w\" sizes=\"(max-width: 1004px) 100vw, 1004px\" \/><\/p>\n<p>Next, use the Save public key and Save private key buttons to save the keys. I suggest naming them such that you can easily tell the difference between the public key, and the private key, e.g. <code>BartBSSKKey-pub.txt<\/code> &#038; <code>BartBSSHKey-priv.ppk<\/code>.<\/p>\n<p style=\"text-align: center\"><img decoding=\"async\" src=\"https:\/\/www.bartbusschots.ie\/s\/wp-content\/uploads\/2020\/02\/Screenshot-2020-02-26-at-12.26.00.png\" alt=\"Screenshot showing PuTTYgen key-pair saving\" width=\"480\" class=\"alignnone size-full wp-image-16315\" style=\"border: 1px solid black\" srcset=\"https:\/\/www.bartbusschots.ie\/s\/wp-content\/uploads\/2020\/02\/Screenshot-2020-02-26-at-12.26.00.png 1004w, https:\/\/www.bartbusschots.ie\/s\/wp-content\/uploads\/2020\/02\/Screenshot-2020-02-26-at-12.26.00-300x296.png 300w, https:\/\/www.bartbusschots.ie\/s\/wp-content\/uploads\/2020\/02\/Screenshot-2020-02-26-at-12.26.00-768x759.png 768w\" sizes=\"(max-width: 1004px) 100vw, 1004px\" \/><\/p>\n<p>The public key is a text file in the standard SSH format, it will look something like:<\/p>\n<pre class=\"crayon:false\">\r\n---- BEGIN SSH2 PUBLIC KEY ----\r\nComment: \"Bart B Windows SSH Key\"\r\nAAAAB3NzaC1yc2EAAAABJQAAAQEAoOk\/uhmDLXUr3iIT7jfGLA\/ZBka9F5M7cgj8\r\nwaHoJ5ZwFCXqLC4rs\/scSZdRkkH7uQLFh\/T\/Pg7Y2xUUGdmQCygh2fmK45HyAlI2\r\ni7F2q9HFiEGYMFU33xD\/to1cEWPCSRylpgg5L01xZR1\/wTjkpWdT5PJL+oNlFUDH\r\nSR5s\/VU1tTWObh\/uWMNyNA9\/+gKPmWzSw2k3Uzg7ZWDo7dztIGrRk3USIqjIMHU1\r\nXW4WRHEjhGxKrhhttatTDWTKhqrJzgjzNL5TwTUtCEsPGrm020Gkwb5eSnHXGgo5\r\n0E7ngitA4SJxuJ2Iv27u47FxBdChG3gn8Uq2wMqNMYYspgXU\/Q==\r\n---- END SSH2 PUBLIC KEY ----\r\n<\/pre>\n<p>This is the file you&#8217;ll need to share with the person operating the servers you&#8217;ll be connecting to.<\/p>\n<p>The private key on the other hand is in a special PuTTY-specific format. The format is human-readable, but it can&#8217;t be used by SSH clients other than PuTTY while in this form. Most conveniently, it contains both the private and public keys, so this is actually the only only file you need to keep safe, you can load it into PuTTYgen at any time and save out the public key again.<\/p>\n<p>If you need a copy of the key in the standard OpenSSH format you can use PuTTYgen to do that using the <em>Conversions<\/em> menu.<\/p>\n<p style=\"text-align: center\"><img decoding=\"async\" src=\"https:\/\/www.bartbusschots.ie\/s\/wp-content\/uploads\/2020\/02\/Screenshot-2020-02-26-at-12.29.03.png\" alt=\"Screenshot showing PuTTYgen private key OpenSSH export\" width=\"480\" class=\"alignnone size-full wp-image-16316\" style=\"border: 1px solid black\" srcset=\"https:\/\/www.bartbusschots.ie\/s\/wp-content\/uploads\/2020\/02\/Screenshot-2020-02-26-at-12.29.03.png 998w, https:\/\/www.bartbusschots.ie\/s\/wp-content\/uploads\/2020\/02\/Screenshot-2020-02-26-at-12.29.03-300x298.png 300w, https:\/\/www.bartbusschots.ie\/s\/wp-content\/uploads\/2020\/02\/Screenshot-2020-02-26-at-12.29.03-150x150.png 150w, https:\/\/www.bartbusschots.ie\/s\/wp-content\/uploads\/2020\/02\/Screenshot-2020-02-26-at-12.29.03-768x763.png 768w\" sizes=\"(max-width: 998px) 100vw, 998px\" \/><\/p>\n<h2>Authorising Access<\/h2>\n<p>In order to use your new SSH key-pair the person administering the server you&#8217;ll be connecting to needs to add your public key into the <code>~\/.ssh\/authorized_keys<\/code> file for the user you&#8217;ll be connecting to the server as.<\/p>\n<h2>Connecting to the Server with the Key<\/h2>\n<p>Once the admin running the server has installed your public key, and given you the server hostname to connect to and username to connect with, you have all the information you need to configure PuTTY to connect to the sever using your key-pair.<\/p>\n<p>Start by opening PuTTY and entering the server name or IP in the <em>Host Name (or IP Address)<\/em> text box, and giving the session you&#8217;re in the process of creating a name in the <em>Saved Settings<\/em> area.<\/p>\n<p style=\"text-align: center\"><img decoding=\"async\" src=\"https:\/\/www.bartbusschots.ie\/s\/wp-content\/uploads\/2020\/02\/Screenshot-2020-02-26-at-12.45.15.png\" alt=\"Screenshot showing PuTTY session creation step 1\" width=\"480\" class=\"alignnone size-full wp-image-16317\" style=\"border: 1px solid black\" srcset=\"https:\/\/www.bartbusschots.ie\/s\/wp-content\/uploads\/2020\/02\/Screenshot-2020-02-26-at-12.45.15.png 936w, https:\/\/www.bartbusschots.ie\/s\/wp-content\/uploads\/2020\/02\/Screenshot-2020-02-26-at-12.45.15-300x300.png 300w, https:\/\/www.bartbusschots.ie\/s\/wp-content\/uploads\/2020\/02\/Screenshot-2020-02-26-at-12.45.15-150x150.png 150w, https:\/\/www.bartbusschots.ie\/s\/wp-content\/uploads\/2020\/02\/Screenshot-2020-02-26-at-12.45.15-768x765.png 768w\" sizes=\"(max-width: 936px) 100vw, 936px\" \/><\/p>\n<p>Next expand the <em>Connection<\/em> section in the left side-bar and choose the <em>Data<\/em> pane under that section. If the username you&#8217;ll be connecting to the server is the same as that you use to log in to Windows choose the Use system username option, otherwise, enter the username in the text box.<\/p>\n<p style=\"text-align: center\"><img decoding=\"async\" src=\"https:\/\/www.bartbusschots.ie\/s\/wp-content\/uploads\/2020\/02\/Screenshot-2020-02-26-at-12.48.24.png\" alt=\"Screenshot showing PuTTY session creation step 2\" width=\"480\" class=\"alignnone size-full wp-image-16318\" style=\"border: 1px solid black\" srcset=\"https:\/\/www.bartbusschots.ie\/s\/wp-content\/uploads\/2020\/02\/Screenshot-2020-02-26-at-12.48.24.png 952w, https:\/\/www.bartbusschots.ie\/s\/wp-content\/uploads\/2020\/02\/Screenshot-2020-02-26-at-12.48.24-300x293.png 300w, https:\/\/www.bartbusschots.ie\/s\/wp-content\/uploads\/2020\/02\/Screenshot-2020-02-26-at-12.48.24-768x750.png 768w\" sizes=\"(max-width: 952px) 100vw, 952px\" \/><\/p>\n<p>Next, expand the <em>SSH<\/em> section (also under <em>Connection<\/em>), and choose the <em>Auth<\/em> pane. Use the Browse button and choose your saved private key (in <code>.ppk<\/code> format).<\/p>\n<p style=\"text-align: center\"><img decoding=\"async\" src=\"https:\/\/www.bartbusschots.ie\/s\/wp-content\/uploads\/2020\/02\/Screenshot-2020-02-26-at-12.51.16.png\" alt=\"Screenshot showing PuTTY session creation step 3\" width=\"480\" class=\"alignnone size-full wp-image-16319\" style=\"border: 1px solid black\" srcset=\"https:\/\/www.bartbusschots.ie\/s\/wp-content\/uploads\/2020\/02\/Screenshot-2020-02-26-at-12.51.16.png 936w, https:\/\/www.bartbusschots.ie\/s\/wp-content\/uploads\/2020\/02\/Screenshot-2020-02-26-at-12.51.16-300x296.png 300w, https:\/\/www.bartbusschots.ie\/s\/wp-content\/uploads\/2020\/02\/Screenshot-2020-02-26-at-12.51.16-768x758.png 768w\" sizes=\"(max-width: 936px) 100vw, 936px\" \/><\/p>\n<p>Finally, navigate back to the front pane by choosing <em>Session<\/em> from the very top of the left side bar and click the Save button to save your preset for future use.<\/p>\n<p>Finally, you can now use the <em>Open<\/em> button to connect to the server. The next time you load PuTTY your session will be available in the list of saved session and can be loaded with the <em>Load<\/em> button.<\/p>\n<p style=\"text-align: center\"><img decoding=\"async\" src=\"https:\/\/www.bartbusschots.ie\/s\/wp-content\/uploads\/2020\/02\/Screenshot-2020-02-26-at-13.17.13.png\" alt=\"Screenshot showing PuTTY session creation step 4\" width=\"480\" class=\"alignnone size-full wp-image-16320\" style=\"border: 1px solid black\" srcset=\"https:\/\/www.bartbusschots.ie\/s\/wp-content\/uploads\/2020\/02\/Screenshot-2020-02-26-at-13.17.13.png 944w, https:\/\/www.bartbusschots.ie\/s\/wp-content\/uploads\/2020\/02\/Screenshot-2020-02-26-at-13.17.13-300x294.png 300w, https:\/\/www.bartbusschots.ie\/s\/wp-content\/uploads\/2020\/02\/Screenshot-2020-02-26-at-13.17.13-768x752.png 768w\" sizes=\"(max-width: 944px) 100vw, 944px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In instalment 30 of the Taming the Terminal series I showed how SSH keys can be used to more securely and conveniently connect to servers. The instructions in that instalment are for Linux-like OSes (including MacOS) where the standard OpenSSH tools are available. Windows doesn&#8217;t ship with OpenSSH (or indeed any SSH implementation), so Windows [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[12,17,446],"tags":[584,538,458,19],"series":[],"class_list":["post-16311","post","type-post","status-publish","format-standard","hentry","category-computers-tech","category-security","category-sysadmin","tag-putty","tag-ssh","tag-tutorial","tag-windows"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p7t9xK-4f5","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/posts\/16311","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/comments?post=16311"}],"version-history":[{"count":4,"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/posts\/16311\/revisions"}],"predecessor-version":[{"id":16326,"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/posts\/16311\/revisions\/16326"}],"wp:attachment":[{"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/media?parent=16311"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/categories?post=16311"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/tags?post=16311"},{"taxonomy":"series","embeddable":true,"href":"https:\/\/www.bartbusschots.ie\/s\/wp-json\/wp\/v2\/series?post=16311"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}