{"id":2618,"date":"2015-03-15T23:15:36","date_gmt":"2015-03-15T22:15:36","guid":{"rendered":"http:\/\/michlstechblog.info\/blog\/?p=2618"},"modified":"2018-10-12T09:57:42","modified_gmt":"2018-10-12T07:57:42","slug":"linux-creating-ssh-keys-with-puttygen","status":"publish","type":"post","link":"https:\/\/michlstechblog.info\/blog\/linux-creating-ssh-keys-with-puttygen\/","title":{"rendered":"Linux: Creating a ssh keypair with puttygen"},"content":{"rendered":"<div class=\"twoclick_social_bookmarks_post_2618 social_share_privacy clearfix 1.6.4 locale-en_US sprite-en_US\"><\/div><div class=\"twoclick-js\"><script type=\"text\/javascript\">\/* <![CDATA[ *\/\njQuery(document).ready(function($){if($('.twoclick_social_bookmarks_post_2618')){$('.twoclick_social_bookmarks_post_2618').socialSharePrivacy({\"services\":{\"flattr\":{\"uid\":\"Michl\",\"status\":\"on\",\"the_title\":\"Linux%3A%20Creating%20a%20ssh%20keypair%20with%20puttygen\",\"the_excerpt\":\"Hi%2C%0D%0A%0D%0Ause%20the%20following%20steps%20to%20create%20a%20ssh%20key%20pair%20with%20puttygen%20and%20import%20the%20public%20key%20on%20a%20linux%20hosts.%0D%0A%0D%0AStart%20puttygen%20and%20generate%20an%204096%20Bit%20RSA%20Key.%0D%0A%0D%0A%0D%0A%0D%0ASet%20a%20strong%20password%20and%20save%20it%20%28D%3A%5Ctemp%5Cprivate.ppk%20in%20this%20example%29%20at%20a%20secure%20location.%0D%0A%20%28more%26hellip%3B%29\",\"txt_info\":\"2 clicks for more data protection:\\r\\n\\r\\nOnly when you click here, the button will be come active and you can send your recommendation to Flattr. When activating, data are transmitted to third parties. \",\"perma_option\":\"off\"}},\"txt_help\":\"When you activate these fields by clicking, information to Flattr may be transferred abroad, and probably may also stored there.\",\"settings_perma\":\"Enable permanently and accept data transmission. \",\"info_link\":\"http:\\\/\\\/www.heise.de\\\/ct\\\/artikel\\\/2-Klicks-fuer-mehr-Datenschutz-1333879.html\",\"uri\":\"https:\\\/\\\/michlstechblog.info\\\/blog\\\/linux-creating-ssh-keys-with-puttygen\\\/\",\"post_id\":2618,\"post_title_referrer_track\":\"Linux%3A+Creating+a+ssh+keypair+with+puttygen\",\"display_infobox\":\"on\"});}});\n\/* ]]> *\/<\/script><\/div><p>Hi,<\/p>\n<p>use the following steps to create a ssh key pair with puttygen and import the public key on a linux hosts.<\/p>\n<p>Start puttygen and generate an 4096 Bit RSA Key.<\/p>\n<figure id=\"attachment_2626\" aria-describedby=\"caption-attachment-2626\" style=\"width: 379px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2015\/03\/generate-key.png\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-2626\" src=\"http:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2015\/03\/generate-key.png\" alt=\"Generate an 4096Bit RSA Key\" width=\"379\" height=\"366\" srcset=\"https:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2015\/03\/generate-key.png 483w, https:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2015\/03\/generate-key-300x290.png 300w\" sizes=\"auto, (max-width: 379px) 100vw, 379px\" \/><\/a><figcaption id=\"caption-attachment-2626\" class=\"wp-caption-text\">Generate an 4096Bit RSA Key<\/figcaption><\/figure>\n<p>Set a strong password and save it (D:\\temp\\private.ppk in this example) at a secure location.<br \/>\n<!--more--><\/p>\n<figure id=\"attachment_2627\" aria-describedby=\"caption-attachment-2627\" style=\"width: 382px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2015\/03\/save-key.png\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-2627\" src=\"http:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2015\/03\/save-key.png\" alt=\"Secure and save your private key\" width=\"382\" height=\"369\" srcset=\"https:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2015\/03\/save-key.png 483w, https:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2015\/03\/save-key-300x290.png 300w\" sizes=\"auto, (max-width: 382px) 100vw, 382px\" \/><\/a><figcaption id=\"caption-attachment-2627\" class=\"wp-caption-text\">Secure and save your private key<\/figcaption><\/figure>\n<p>Export your private key as OpenSSH compatible key (for example D:\\temp\\private.key) and copy the key to your linux box.<\/p>\n<figure id=\"attachment_2628\" aria-describedby=\"caption-attachment-2628\" style=\"width: 391px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2015\/03\/export-openssh-key.png\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-2628\" src=\"http:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2015\/03\/export-openssh-key.png\" alt=\"Export your key in openssh format\" width=\"391\" height=\"377\" srcset=\"https:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2015\/03\/export-openssh-key.png 484w, https:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2015\/03\/export-openssh-key-300x289.png 300w\" sizes=\"auto, (max-width: 391px) 100vw, 391px\" \/><\/a><figcaption id=\"caption-attachment-2628\" class=\"wp-caption-text\">Export your key in openssh format<\/figcaption><\/figure>\n<p>Copy the key to the your home directory<\/p>\n<p><code>d:\\&gt; pscp d:\\temp\\private.key michael@devdeb:.ssh\/id_rsa<\/code><\/p>\n<p>Export your public key to ~\/.ssh\/id_rsa.pub<\/p>\n<p><code><br \/>\nmichael@devdebt &gt;  chmod 600 ~\/id_rsa<br \/>\nmichael@devdebt &gt;\u00a0 ssh-keygen -e -f ~\/id_rsa &gt; ~\/.ssh\/id_rsa.pub<br \/>\n<\/code><\/p>\n<p><code><br \/>\nmichael@debdevt:~\/.ssh $ cat id_rsa.pub<br \/>\n---- BEGIN SSH2 PUBLIC KEY ----<br \/>\nComment: \"4096-bit RSA, converted by michael@debdevt from OpenSSH\"<br \/>\nAAAAB3NzaC1yc2EAAAABJQAAAgEAmlBW8LR5J4E8NbiyrYZQxN9RsFjfP9pwPJbOcUVlop<br \/>\nv+u5TIZm8S6AW3sVFTElYgeQoi5f3csvfQBIAWCu+yTB8\/q7b1gqk9TIGfxQS1mJHhit+v<br \/>\n3cGb\/QKazqN0wz357keEZxP5kl4q4YBSEtUIVfvlLghuLNu53CjpexrSX31q9KwzSY7vUO<br \/>\nRpOYwbWNJb\/hAudXfUk2nDMdPtVzte8hPpq73apFT1nORFSAI1TZlj3rVubX0434iGrK7O<br \/>\n6gbjGJjukxeqDVWjYSFpk2MROwUnnJWgS0ueRBu2gsaDIEw6qx9vIEKcj0O30uZvyPc9\/I<br \/>\ni1K9PKAnmzv+zUTLqLw9+vxNM3hueGXbk25Qv4aFuxzz8vpIh5qP5ZVswMm5+nis6paYXH<br \/>\nwStZc1yUVeL5XYVjZoBZ4+3jsQUOcBEWFACsxWP6HaLbuxl+DaGO\/f6sPYC0QuOydFgV9W<br \/>\nJcjXzmodnAoh5mBHZKTLDJEIOmrHVX2PT5iQoDljRPO1xtP4j5AkcAaNfyT51FNgdeRyRj<br \/>\nzklK6Lqkem3V\/CakfBzzySgDs3VUrkZnFDXkGjKqnR9v91PzzpcZQ13VS4kZvc04vbsAJN<br \/>\nh5c\/X+aTHcwJv2vlV82nNumur686gZW0BriKtvkJiurHKmlxtPLwlbZ3vl0IVM6nhloBDS<br \/>\nhuun\/WUa\/oM=<br \/>\n---- END SSH2 PUBLIC KEY ----<\/code><\/p>\n<p>Add the public key to file ~\/.ssh\/authorized_keys. You have to convert id_rsa.pub (SSH2 PUBLIC KEY format) to the format authorized_keys expects and set the correct file permissions. Convert it &#8220;manually&#8221;:<\/p>\n<pre><code>\r\nmichael@debdevt:~\/.ssh # echo -n\u00a0 \"ssh-rsa \" &gt;&gt; ~\/.ssh\/authorized_keys\r\nmichael@debdevt:~\/.ssh # cat ~\/.ssh\/id_rsa.pub | tail -n+3\u00a0 | head -n-1 |tr -d '\\n' &gt;&gt; ~\/.ssh\/authorized_keys\r\nmichael@debdevt:~\/.ssh # echo \" ${USER}@${HOSTNAME}\" &gt;&gt; ~\/.ssh\/authorized_keys\r\n<\/code><\/pre>\n<p>or use ssh-keygen<\/p>\n<pre><code>\r\nmichael@debdevt:~\/.ssh #  ssh-keygen -i -f id_rsa.pub &gt;&gt; authorized_keys\r\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>Set permissions<\/p>\n<pre><code>\r\nmichael@debdevt:~\/.ssh # chmod 600 ~\/.ssh\/authorized_keys\r\n<\/code><\/pre>\n<p>A line like this was added<br \/>\n<code>michael@debdevt:~$ cat .ssh\/authorized_keys<br \/>\nssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAgEAmlBW8LR5J4E8NbiyrYZQxN9RsFjfP9pwPJbOcUV<br \/>\nlopv+u5TIZm8S6AW3sVFTElYgeQoi5f3csvfQBIAWCu+yTB8\/q7b1gqk9TIGfxQS1mJHhit+v3c<br \/>\nGb\/QKazqN0wz357keEZxP5kl4q4YBSEtUIVfvlLghuLNu53CjpexrSX31q9KwzSY7vUORpOYwbW<br \/>\nNJb\/hAudXfUk2nDMdPtVzte8hPpq73apFT1nORFSAI1TZlj3rVubX0434iGrK7O6gbjGJjukxeq<br \/>\nDVWjYSFpk2MROwUnnJWgS0ueRBu2gsaDIEw6qx9vIEKcj0O30uZvyPc9\/Ii1K9PKAnmzv+zUTLq<br \/>\nLw9+vxNM3hueGXbk25Qv4aFuxzz8vpIh5qP5ZVswMm5+nis6paYXHwStZc1yUVeL5XYVjZoBZ4+<br \/>\n3jsQUOcBEWFACsxWP6HaLbuxl+DaGO\/f6sPYC0QuOydFgV9WJcjXzmodnAoh5mBHZKTLDJEIOmr<br \/>\nHVX2PT5iQoDljRPO1xtP4j5AkcAaNfyT51FNgdeRyRjzklK6Lqkem3V\/CakfBzzySgDs3VUrkZn<br \/>\nFDXkGjKqnR9v91PzzpcZQ13VS4kZvc04vbsAJNh5c\/X+aTHcwJv2vlV82nNumur686gZW0BriKt<br \/>\nvkJiurHKmlxtPLwlbZ3vl0IVM6nhloBDShuun\/WUa\/oM= michael@debdevt<br \/>\n<\/code><\/p>\n<p>If you want to copy your public key to other boxes. Convert SSH2 PUBLIC KEY format and copy the file<\/p>\n<pre><code>\r\nmichael@debdevt:~\/.ssh # ssh-keygen -i -f id_rsa.pub &gt; id_rsa\r\nmichael@debdevt:~\/.ssh # ssh-copy-id -f -i ~\/.ssh\/id_rsa michael@debdev2\r\n<\/code><\/pre>\n<p>Configure your PuTTY Session to use the ssh key<\/p>\n<figure id=\"attachment_2638\" aria-describedby=\"caption-attachment-2638\" style=\"width: 370px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2015\/03\/login-with-private-key.png\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-2638\" src=\"http:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2015\/03\/login-with-private-key.png\" alt=\"Configure PuTTY to use the ssh key\" width=\"370\" height=\"481\" srcset=\"https:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2015\/03\/login-with-private-key.png 456w, https:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2015\/03\/login-with-private-key-231x300.png 231w\" sizes=\"auto, (max-width: 370px) 100vw, 370px\" \/><\/a><figcaption id=\"caption-attachment-2638\" class=\"wp-caption-text\">Configure PuTTY to use the ssh key<\/figcaption><\/figure>\n<p>And Login to your linux box<\/p>\n<figure id=\"attachment_2639\" aria-describedby=\"caption-attachment-2639\" style=\"width: 581px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2015\/03\/login.png\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-2639\" src=\"http:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2015\/03\/login.png\" alt=\"Login\" width=\"581\" height=\"363\" srcset=\"https:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2015\/03\/login.png 755w, https:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2015\/03\/login-300x188.png 300w\" sizes=\"auto, (max-width: 581px) 100vw, 581px\" \/><\/a><figcaption id=\"caption-attachment-2639\" class=\"wp-caption-text\">Login<\/figcaption><\/figure>\n<p>Have fun \ud83d\ude42<\/p>\n<p>Michael<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi, use the following steps to create a ssh key pair with puttygen and import the public key on a linux hosts. Start puttygen and generate an 4096 Bit RSA Key. Set a strong password and save it (D:\\temp\\private.ppk in this example) at a secure location.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[632,224,633,630,631,194],"class_list":["post-2618","post","type-post","status-publish","format-standard","hentry","category-linux","tag-keys-convert","tag-linux-2","tag-openssh","tag-putty","tag-puttygen","tag-ssh"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/2618","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/comments?post=2618"}],"version-history":[{"count":31,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/2618\/revisions"}],"predecessor-version":[{"id":5855,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/2618\/revisions\/5855"}],"wp:attachment":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/media?parent=2618"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/categories?post=2618"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/tags?post=2618"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}