{"id":6868,"date":"2020-03-04T22:20:41","date_gmt":"2020-03-04T21:20:41","guid":{"rendered":"https:\/\/michlstechblog.info\/blog\/?p=6868"},"modified":"2020-03-05T10:39:09","modified_gmt":"2020-03-05T09:39:09","slug":"linux-creating-a-ssh-keypair-with-ssh-keygen","status":"publish","type":"post","link":"https:\/\/michlstechblog.info\/blog\/linux-creating-a-ssh-keypair-with-ssh-keygen\/","title":{"rendered":"Linux: Creating a ssh keypair with ssh-keygen"},"content":{"rendered":"<div class=\"twoclick_social_bookmarks_post_6868 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_6868')){$('.twoclick_social_bookmarks_post_6868').socialSharePrivacy({\"services\":{\"flattr\":{\"uid\":\"Michl\",\"status\":\"on\",\"the_title\":\"Linux%3A%20Creating%20a%20ssh%20keypair%20with%20ssh-keygen\",\"the_excerpt\":\"Hi%2C%0D%0A%0D%0Assh-keygen%20can%20be%20used%20to%20generate%20a%20new%20ssh%20key%20pair.%0D%0A%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-a-ssh-keypair-with-ssh-keygen\\\/\",\"post_id\":6868,\"post_title_referrer_track\":\"Linux%3A+Creating+a+ssh+keypair+with+ssh-keygen\",\"display_infobox\":\"on\"});}});\n\/* ]]> *\/<\/script><\/div><p>Hi,<\/p>\n<p>ssh-keygen can be used to generate a new ssh key pair.<\/p>\n<p><!--more--><\/p>\n<p>To generate a new pair use the following command line which store both, private an d public key, in $HOME\/MyGeneratedKeys (default directory $HOME\/.ssh). <\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nmichael@debdev ~ # mkdir MyGeneratedKeys \r\nmichael@debdev ~ # ssh-keygen -b 2048 -t rsa -f $HOME\/MyGeneratedKeys\/id_rsa -C &quot;My ssh key&quot;\r\nEnter passphrase (empty for no passphrase):\r\nEnter same passphrase again:\r\nYour identification has been saved in \/home\/michael\/MyGeneratedKeys\/id_rsa.\r\nYour public key has been saved in \/home\/michael\/MyGeneratedKeys\/id_rsa.pub.\r\nThe key fingerprint is:\r\nSHA256:4fcRXik1VAyxoVAvLZTb4FvjjI7yGIQUQ3w7VCmF6lI My ssh key\r\nThe key's randomart image is:\r\n+---&#x5B;RSA 2048]----+\r\n|     o+  ++oooB=.|\r\n|      .o= .oo= =.|\r\n|      .+.o .*+*  |\r\n|     .Eoo. .o*+  |\r\n|     o. S.. o* . |\r\n|    . .. . .o.o  |\r\n|     .  .  o.    |\r\n|        .o. .    |\r\n|        .o.      |\r\n+----&#x5B;SHA256]-----+\r\n<\/pre>\n<p>To use it start the ssh-agent and add the keys. ssh-agent prints out the socket (SSH_AUTH_SOCK) and the ssh-agent PID (SSH_AGENT_PID) which have to set as environment variables. eval combined with ssh-agent does this in one step.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nmichael@debdev ~ # eval `ssh-agent`\r\nmichael@debdev ~ # set|grep SSH_\r\nSSH_AGENT_PID=3899\r\nSSH_AUTH_SOCK=\/tmp\/ssh-pL4CiUVIdGK7\/agent.3898\r\nmichael@debdev ~ # ssh-add \/home\/michael\/MyGeneratedKeys\/id_rsa\r\n<\/pre>\n<p>If you want to use the new key with putty you have to convert it with puttygen.<\/p>\n<p>Load the private key<br \/>\n<a href=\"https:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2020\/03\/putty-load-private-key.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2020\/03\/putty-load-private-key.png\" alt=\"\" width=\"477\" height=\"471\" class=\"alignnone size-full wp-image-6876\" srcset=\"https:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2020\/03\/putty-load-private-key.png 477w, https:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2020\/03\/putty-load-private-key-300x296.png 300w\" sizes=\"auto, (max-width: 477px) 100vw, 477px\" \/><\/a><\/p>\n<p>Note: Set filter to all files *.*<br \/>\n<a href=\"https:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2020\/03\/putty-choose-file.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2020\/03\/putty-choose-file.png\" alt=\"\" width=\"728\" height=\"299\" class=\"alignnone size-full wp-image-6874\" srcset=\"https:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2020\/03\/putty-choose-file.png 728w, https:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2020\/03\/putty-choose-file-300x123.png 300w\" sizes=\"auto, (max-width: 728px) 100vw, 728px\" \/><\/a><\/p>\n<p>enter passphrase<br \/>\n<a href=\"https:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2020\/03\/putty-key-passphrase.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2020\/03\/putty-key-passphrase.png\" alt=\"\" width=\"212\" height=\"130\" class=\"alignnone size-full wp-image-6875\" \/><\/a><\/p>\n<p>And save it as putty key<br \/>\n<a href=\"https:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2020\/03\/putty-private-key-save-as-putty-private-key.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2020\/03\/putty-private-key-save-as-putty-private-key.png\" alt=\"\" width=\"479\" height=\"471\" class=\"alignnone size-full wp-image-6878\" srcset=\"https:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2020\/03\/putty-private-key-save-as-putty-private-key.png 479w, https:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2020\/03\/putty-private-key-save-as-putty-private-key-300x295.png 300w\" sizes=\"auto, (max-width: 479px) 100vw, 479px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2020\/03\/putty-private-key-save-as-putty-private-key-ppk.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2020\/03\/putty-private-key-save-as-putty-private-key-ppk.png\" alt=\"\" width=\"728\" height=\"299\" class=\"alignnone size-full wp-image-6877\" srcset=\"https:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2020\/03\/putty-private-key-save-as-putty-private-key-ppk.png 728w, https:\/\/michlstechblog.info\/blog\/wp-content\/uploads\/2020\/03\/putty-private-key-save-as-putty-private-key-ppk-300x123.png 300w\" sizes=\"auto, (max-width: 728px) 100vw, 728px\" \/><\/a><\/p>\n<p>Michael<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi, ssh-keygen can be used to generate a new ssh key pair.<\/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":[1418,651,838,224,1176,1175,194],"class_list":["post-6868","post","type-post","status-publish","format-standard","hentry","category-linux","tag-convert-to-putty-key","tag-generate","tag-key","tag-linux-2","tag-private","tag-public","tag-ssh"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/6868","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=6868"}],"version-history":[{"count":7,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/6868\/revisions"}],"predecessor-version":[{"id":6881,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/posts\/6868\/revisions\/6881"}],"wp:attachment":[{"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/media?parent=6868"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/categories?post=6868"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/michlstechblog.info\/blog\/wp-json\/wp\/v2\/tags?post=6868"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}