{"id":46,"date":"2013-11-26T13:47:09","date_gmt":"2013-11-26T13:47:09","guid":{"rendered":"http:\/\/etapien.com\/guides\/?p=46"},"modified":"2020-08-24T14:22:37","modified_gmt":"2020-08-24T19:22:37","slug":"how-to-create-a-private-and-public-key-pair-with-puttygen","status":"publish","type":"post","link":"https:\/\/etapien.com\/guides\/how-to-create-a-private-and-public-key-pair-with-puttygen\/","title":{"rendered":"How to create a private and public key pair with PUTTYGEN"},"content":{"rendered":"<h1>Introduction<\/h1>\n<p>This guide describes how to generate and use a private\/public key pair to log in to a remote system with SSH using PuTTY. Using key-based SSH logins, you can disable the normal username\/password login procedure which means that only people with a valid private\/public key pair can log in. That way, there is no way for brute-force attacks to be successful, so your system is more secure.<\/p>\n<p>&nbsp;<\/p>\n<h2>Prerequisites<\/h2>\n<p>First we need to download <a href=\"http:\/\/the.earth.li\/%7Esgtatham\/putty\/latest\/x86\/puttygen.exe\" target=\"_blank\" rel=\"noopener noreferrer\">PuTTYgen<\/a>\u00a0on our Windows system. PUTTYgen only usage is to create the private\/public key pair, we then need <a href=\"http:\/\/the.earth.li\/%7Esgtatham\/putty\/latest\/x86\/putty.exe\" target=\"_blank\" rel=\"noopener noreferrer\">Putty<\/a>\u00a0to connect to the VPS.\u00a0Both PUTTYgen and Putty can be downloaded from this page <a href=\"http:\/\/www.chiark.greenend.org.uk\/%7Esgtatham\/putty\/download.html\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a>.<\/p>\n<p>Download the exectuable files (.exe) and save them on the desktop. The files are stand alone applications so no installation is needed. Start PUTTYgen by double-clicking on it.<\/p>\n<h2>Create the key pair<\/h2>\n<p>We will use PuTTYgen to create a private\/public key pair. When started, find <em><strong>Type of key to generate<\/strong><\/em>\u00a0and\u00a0select <em><strong>SSH-2 RSA <\/strong><\/em>and then set\u00a0<em><strong>Number of bits in a generated key<\/strong><\/em> to <em><strong>1024<\/strong><\/em>.<\/p>\n<p><a href=\"http:\/\/www.lowendguide.com\/wordpress\/wp-content\/uploads\/2013\/07\/puttygen-1.png\"><img decoding=\"async\" loading=\"lazy\" alt=\"puttygen-1\" src=\"http:\/\/www.lowendguide.com\/wordpress\/wp-content\/uploads\/2013\/07\/puttygen-1-300x288.png\" width=\"300\" height=\"288\" \/><\/a><\/p>\n<p>Then click on <em><strong>Generate<\/strong> <\/em>and\u00a0move the mouse pointer over the blank area during the key generation to generate some randomness:<\/p>\n<p><a href=\"http:\/\/www.lowendguide.com\/wordpress\/wp-content\/uploads\/2013\/07\/puttygen-2.png\"><img decoding=\"async\" loading=\"lazy\" alt=\"puttygen-2\" src=\"http:\/\/www.lowendguide.com\/wordpress\/wp-content\/uploads\/2013\/07\/puttygen-2-300x289.png\" width=\"300\" height=\"289\" \/><\/a><\/p>\n<p>When the private\/public key pair has been generated it\u2019s time to enter a comment to keep track of the key pair. Under <strong><em>Key comment<\/em><\/strong>, enter anthing you want but a pro tip is to enter something descriptive of the purpose of the key pair.<\/p>\n<h2>Save the public key<\/h2>\n<p>Then click on Save public key and save it in some safe location on your computer. You are free to choose a filename and extension, but it should be one that lets you remember for which system it is.<\/p>\n<p><a href=\"http:\/\/www.lowendguide.com\/wordpress\/wp-content\/uploads\/2013\/07\/puttygen-3.png\"><img decoding=\"async\" loading=\"lazy\" alt=\"puttygen-3\" src=\"http:\/\/www.lowendguide.com\/wordpress\/wp-content\/uploads\/2013\/07\/puttygen-3-300x287.png\" width=\"300\" height=\"287\" \/><\/a><\/p>\n<h2>Save the private key<\/h2>\n<p>Before we save the private key we should enter a <strong>Key passphrase<\/strong> and repeat it under <em><strong>Confirm passphrase<\/strong><\/em>.\u00a0The passphrase will be used to encrypt the key on disk, without the passphrase you will not be able to use the key and it would be of no use. \u00a0If you leave the passphrase fields blank, the key will be saved unencrypted.\u00a0Sometimes you may need\u00a0to use a key with no passphrase like when you need to run some automated script that will connect via SSH and you can\u2019t be there everytime to enter the passphrase. For this type of keys you shoulf generate a special key for each specific script, that way it\u2019s easier to remove the access when job is done or the private key is\u00a0compromised.<\/p>\n<p>&nbsp;<\/p>\n<p>When the passphrase has been entered click on<em><strong> Save private key<\/strong><\/em>. You can save it in the same location as the public key but whatever you do, don\u2019t lose it. If you do and have disabled username\/password logins, you will not be able to login anymore!<\/p>\n<p>Choose a filename, the only restriction is that the extension must be .ppk:<\/p>\n<h2>Add the public key to your server<\/h2>\n<p>Select All text in the textbox <em><strong>Public key for pasting into OpenSSH authorized_keys file, <\/strong><\/em>right-click\u00a0and copy the public key from the PuTTYgen window:<\/p>\n<p><a href=\"http:\/\/www.lowendguide.com\/wordpress\/wp-content\/uploads\/2013\/07\/puttygen-4.png\"><img decoding=\"async\" loading=\"lazy\" alt=\"puttygen-4\" src=\"http:\/\/www.lowendguide.com\/wordpress\/wp-content\/uploads\/2013\/07\/puttygen-4-300x287.png\" width=\"300\" height=\"287\" \/><\/a><\/p>\n<p>Connect to your server using the root username and password, and paste the public key into the file<\/p>\n<pre><code>~\/.ssh\/authorized_keys<\/code><\/pre>\n<p>If the directory\u00a0<strong><em>~\/.ssh<\/em><\/strong> is not available, create it with the following commands:<\/p>\n<pre><code>mkdir ~\/.ssh\r\nchmod 700 ~\/.ssh<\/code><\/pre>\n<p>Edit the <em><strong>authorized_keys\u00a0<\/strong><\/em>file with nano:<\/p>\n<pre><code>nano~\/.ssh\/authorized_keys<\/code><\/pre>\n<p>and paste the content in one single line!<\/p>\n<p>That <em><strong>authorized_keys\u00a0<\/strong><\/em>file must be write\/readable only by that user, so we chmod it:<\/p>\n<pre><code>chmod 600 ~\/.ssh\/authorized_keys<\/code><\/pre>\n<p>Save and exit nano and all is done on the server side.<\/p>\n<p>&nbsp;<\/p>\n<h2>Tell Putty to use the private key when connecting to your server<\/h2>\n<p>Start Putty and from the Category window, select <em><strong>Connection | SSH | Auth<\/strong><\/em> and click the <strong><em>Browse\u2026<\/em><\/strong> button.<\/p>\n<p><a href=\"http:\/\/www.lowendguide.com\/wordpress\/wp-content\/uploads\/2013\/07\/putty-5.png\"><img decoding=\"async\" loading=\"lazy\" alt=\"putty-5\" src=\"http:\/\/www.lowendguide.com\/wordpress\/wp-content\/uploads\/2013\/07\/putty-5-300x288.png\" width=\"300\" height=\"288\" \/><\/a><\/p>\n<p>Browse to your .ppk file and select open.<\/p>\n<p>If you want to\u00a0automatically fill in the username when opening your connection you can enter that information in the Category <em><strong>Connection | Data<\/strong><\/em>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This guide describes how to generate and use a private\/public key pair to log in to a remote system with SSH using PuTTY. Using key-based SSH logins, you can disable the normal username\/password login procedure which means that only people with a valid private\/public key pair can log in. That way, there is no way for brute-force attacks to be successful, so your system is more secure.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[26,27,28,25],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to create a private and public key pair with PUTTYGEN - Tech Howtos<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/etapien.com\/guides\/how-to-create-a-private-and-public-key-pair-with-puttygen\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to create a private and public key pair with PUTTYGEN - Tech Howtos\" \/>\n<meta property=\"og:description\" content=\"This guide describes how to generate and use a private\/public key pair to log in to a remote system with SSH using PuTTY. Using key-based SSH logins, you can disable the normal username\/password login procedure which means that only people with a valid private\/public key pair can log in. That way, there is no way for brute-force attacks to be successful, so your system is more secure.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/etapien.com\/guides\/how-to-create-a-private-and-public-key-pair-with-puttygen\/\" \/>\n<meta property=\"og:site_name\" content=\"Tech Howtos\" \/>\n<meta property=\"article:published_time\" content=\"2013-11-26T13:47:09+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-08-24T19:22:37+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.lowendguide.com\/wordpress\/wp-content\/uploads\/2013\/07\/puttygen-1-300x288.png\" \/>\n<meta name=\"author\" content=\"Etapien\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Etapien\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/etapien.com\/guides\/how-to-create-a-private-and-public-key-pair-with-puttygen\/\",\"url\":\"https:\/\/etapien.com\/guides\/how-to-create-a-private-and-public-key-pair-with-puttygen\/\",\"name\":\"How to create a private and public key pair with PUTTYGEN - Tech Howtos\",\"isPartOf\":{\"@id\":\"https:\/\/etapien.com\/guides\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/etapien.com\/guides\/how-to-create-a-private-and-public-key-pair-with-puttygen\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/etapien.com\/guides\/how-to-create-a-private-and-public-key-pair-with-puttygen\/#primaryimage\"},\"thumbnailUrl\":\"http:\/\/www.lowendguide.com\/wordpress\/wp-content\/uploads\/2013\/07\/puttygen-1-300x288.png\",\"datePublished\":\"2013-11-26T13:47:09+00:00\",\"dateModified\":\"2020-08-24T19:22:37+00:00\",\"author\":{\"@id\":\"https:\/\/etapien.com\/guides\/#\/schema\/person\/c67f514649b78dbb5ef0c254a0521424\"},\"breadcrumb\":{\"@id\":\"https:\/\/etapien.com\/guides\/how-to-create-a-private-and-public-key-pair-with-puttygen\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/etapien.com\/guides\/how-to-create-a-private-and-public-key-pair-with-puttygen\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/etapien.com\/guides\/how-to-create-a-private-and-public-key-pair-with-puttygen\/#primaryimage\",\"url\":\"http:\/\/www.lowendguide.com\/wordpress\/wp-content\/uploads\/2013\/07\/puttygen-1-300x288.png\",\"contentUrl\":\"http:\/\/www.lowendguide.com\/wordpress\/wp-content\/uploads\/2013\/07\/puttygen-1-300x288.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/etapien.com\/guides\/how-to-create-a-private-and-public-key-pair-with-puttygen\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/etapien.com\/guides\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to create a private and public key pair with PUTTYGEN\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/etapien.com\/guides\/#website\",\"url\":\"https:\/\/etapien.com\/guides\/\",\"name\":\"Tech Howtos\",\"description\":\"Tech related useful howtos\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/etapien.com\/guides\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/etapien.com\/guides\/#\/schema\/person\/c67f514649b78dbb5ef0c254a0521424\",\"name\":\"Etapien\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/etapien.com\/guides\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/55021fd8fb4a829ad64ffab0a92d3b90?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/55021fd8fb4a829ad64ffab0a92d3b90?s=96&d=mm&r=g\",\"caption\":\"Etapien\"},\"url\":\"https:\/\/etapien.com\/guides\/author\/Etapien\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to create a private and public key pair with PUTTYGEN - Tech Howtos","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/etapien.com\/guides\/how-to-create-a-private-and-public-key-pair-with-puttygen\/","og_locale":"en_US","og_type":"article","og_title":"How to create a private and public key pair with PUTTYGEN - Tech Howtos","og_description":"This guide describes how to generate and use a private\/public key pair to log in to a remote system with SSH using PuTTY. Using key-based SSH logins, you can disable the normal username\/password login procedure which means that only people with a valid private\/public key pair can log in. That way, there is no way for brute-force attacks to be successful, so your system is more secure.","og_url":"https:\/\/etapien.com\/guides\/how-to-create-a-private-and-public-key-pair-with-puttygen\/","og_site_name":"Tech Howtos","article_published_time":"2013-11-26T13:47:09+00:00","article_modified_time":"2020-08-24T19:22:37+00:00","og_image":[{"url":"http:\/\/www.lowendguide.com\/wordpress\/wp-content\/uploads\/2013\/07\/puttygen-1-300x288.png"}],"author":"Etapien","twitter_misc":{"Written by":"Etapien","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/etapien.com\/guides\/how-to-create-a-private-and-public-key-pair-with-puttygen\/","url":"https:\/\/etapien.com\/guides\/how-to-create-a-private-and-public-key-pair-with-puttygen\/","name":"How to create a private and public key pair with PUTTYGEN - Tech Howtos","isPartOf":{"@id":"https:\/\/etapien.com\/guides\/#website"},"primaryImageOfPage":{"@id":"https:\/\/etapien.com\/guides\/how-to-create-a-private-and-public-key-pair-with-puttygen\/#primaryimage"},"image":{"@id":"https:\/\/etapien.com\/guides\/how-to-create-a-private-and-public-key-pair-with-puttygen\/#primaryimage"},"thumbnailUrl":"http:\/\/www.lowendguide.com\/wordpress\/wp-content\/uploads\/2013\/07\/puttygen-1-300x288.png","datePublished":"2013-11-26T13:47:09+00:00","dateModified":"2020-08-24T19:22:37+00:00","author":{"@id":"https:\/\/etapien.com\/guides\/#\/schema\/person\/c67f514649b78dbb5ef0c254a0521424"},"breadcrumb":{"@id":"https:\/\/etapien.com\/guides\/how-to-create-a-private-and-public-key-pair-with-puttygen\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/etapien.com\/guides\/how-to-create-a-private-and-public-key-pair-with-puttygen\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/etapien.com\/guides\/how-to-create-a-private-and-public-key-pair-with-puttygen\/#primaryimage","url":"http:\/\/www.lowendguide.com\/wordpress\/wp-content\/uploads\/2013\/07\/puttygen-1-300x288.png","contentUrl":"http:\/\/www.lowendguide.com\/wordpress\/wp-content\/uploads\/2013\/07\/puttygen-1-300x288.png"},{"@type":"BreadcrumbList","@id":"https:\/\/etapien.com\/guides\/how-to-create-a-private-and-public-key-pair-with-puttygen\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/etapien.com\/guides\/"},{"@type":"ListItem","position":2,"name":"How to create a private and public key pair with PUTTYGEN"}]},{"@type":"WebSite","@id":"https:\/\/etapien.com\/guides\/#website","url":"https:\/\/etapien.com\/guides\/","name":"Tech Howtos","description":"Tech related useful howtos","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/etapien.com\/guides\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/etapien.com\/guides\/#\/schema\/person\/c67f514649b78dbb5ef0c254a0521424","name":"Etapien","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/etapien.com\/guides\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/55021fd8fb4a829ad64ffab0a92d3b90?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/55021fd8fb4a829ad64ffab0a92d3b90?s=96&d=mm&r=g","caption":"Etapien"},"url":"https:\/\/etapien.com\/guides\/author\/Etapien\/"}]}},"_links":{"self":[{"href":"https:\/\/etapien.com\/guides\/wp-json\/wp\/v2\/posts\/46"}],"collection":[{"href":"https:\/\/etapien.com\/guides\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/etapien.com\/guides\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/etapien.com\/guides\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/etapien.com\/guides\/wp-json\/wp\/v2\/comments?post=46"}],"version-history":[{"count":3,"href":"https:\/\/etapien.com\/guides\/wp-json\/wp\/v2\/posts\/46\/revisions"}],"predecessor-version":[{"id":259,"href":"https:\/\/etapien.com\/guides\/wp-json\/wp\/v2\/posts\/46\/revisions\/259"}],"wp:attachment":[{"href":"https:\/\/etapien.com\/guides\/wp-json\/wp\/v2\/media?parent=46"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/etapien.com\/guides\/wp-json\/wp\/v2\/categories?post=46"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/etapien.com\/guides\/wp-json\/wp\/v2\/tags?post=46"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}