{"id":1748,"date":"2019-11-16T19:08:17","date_gmt":"2019-11-16T19:08:17","guid":{"rendered":"http:\/\/linuxdigest.com\/?p=1748"},"modified":"2021-01-24T13:08:44","modified_gmt":"2021-01-24T13:08:44","slug":"how-to-generate-ssh-key","status":"publish","type":"post","link":"https:\/\/linuxdigest.com\/howto\/how-to-generate-ssh-key\/","title":{"rendered":"How to generate an SSH key"},"content":{"rendered":"\n<p>Having a SSH key can be very handy to avoid having to enter your password every time you connect to a server via SSH. You can create a SSH key in your terminal in just a few seconds.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. Open your terminal<\/h2>\n\n\n\n<h2 class=\"wp-block-heading\">2. Start the ssh-keygen tool<\/h2>\n\n\n\n<p>The ssh-keygen tool is included in the openssh-client package.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ssh-keygen -t rsa -b 4096<\/code><\/pre>\n\n\n\n<p>This will make a SSH key with the type RSA and bit length of 4096. This is larger than the default of 2048 bits.  A larger key can be more secure. 4096 bits should be sufficient here.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3. Press enter to save in the default location<\/h2>\n\n\n\n<p>If this is not your first SSH key. You can also enter a new path to save the file.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Generating public\/private rsa key pair.\n\nEnter file in which to save the key (\/root\/.ssh\/id_rsa):<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">4. Decide on a passphrase or no passphrase<\/h2>\n\n\n\n<p>If you enter a passphrase here. You will have to enter this phrase every time you use the key. If you don&#8217;t want a passphrase, just press enter.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">5. Start using your new key!<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>Your identification has been saved in \/myuser\/.ssh\/id_rsa.\n Your public key has been saved in \/myuser\/.ssh\/id_rsa.pub.\n The key fingerprint is:\n SHA256:XbSuo8IpvoaHmwSuaWhnj7F0m0kuiB99a7ikpEq4yzA myuser@desktop\n The key's randomart image is:\n +---&#91;RSA 4096]----+\n |            .    |\n |           . .   |\n |            o    |\n |         . o     |\n |.       S . .    |\n |o. .       .     |\n |Eo==o=..  o      |\n |B@+O%.O. . .     |\n |@+BB*@\u2026          |\n +----&#91;SHA256]-----+<\/code><\/pre>\n\n\n\n<p>The ssh-key tool has now saved two files in your ~\/.ssh directory:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">id_rsa<\/h3>\n\n\n\n<p>This is your public key. The contents of this file will be stored on the servers you need access to.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">6. Put your public key where ever you need to use it<\/h2>\n\n\n\n<p>There are two ways you can copy your public key to a Linux server.<\/p>\n\n\n\n<p>The quickest way is to use ssh-copy-id. This will automatically add the key to the remote users authorized keys:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ssh-copy-id root@myserver.example.com<\/code><\/pre>\n\n\n\n<p>An other way is to manually add the key to the servers authorized keys file.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cat  ~\/.ssh\/id_rsa.pub \n ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDV+mzuCEKk5qg1z0hKzKerNn8F4XD7o4PyTsCnUNWjWNtlfaY1IYw\/QtYxeBh4blDuCXSyJNgf46eYiebjPCD8Vi3cpbqKxlVZKSxBnmhYSh6BVL+jlsxDgv\/S0IueUp+KirIsnLC7c6q+dmbebZeuik5DwTS4i5njxBsZTK4E+y7q5Y6L7CzoKn7axdXlVnHs2e6z5mlQ0sFef0E0L9bwQzUwWP2+yQoUP5LsKRaDl6kOb6l8Dx6wNd1ycFyrBhntQyAWEIscfIR1eHU4DkhkIwqC328grBP6jjPxVhsl1cJdQPqs6GbLqUmddyCRLYVWTFHKnJ+X8Fh5DHNIcDHbCr8Mhqt1C2S9LVM9DEKnmkMmH3Ev6Fwa8HA83DJMqYBM4+UIWGtzZvP1DYqUxY7ixSvSh2OkReluHzo1u9cC8k1v6h2TOFoZUaQQNGN\/aU2lMSXVm5AH240amPd9OygMiH+Kzd+JriQ5WztwXXZ9UxqRi1SZWvzU+KIHW6oYEBbZbrfsWSv0Q6Cih6UMdaUMn3XAqQMJ5O7Crgy4yjVoL+9umxo2q9AAzH+YdSgrbnNXovWP0Jpcgj0bsRX6rVC70usvqYueocxk6\/X8wEiBrAKJl9yACP1PIwpYKKCSSLN+92Gr5t\/9HDJpWimV67xH7ub7JL+M0TQlD7h+6S0GKQ== myuser@desktop<\/code><\/pre>\n\n\n\n<p>Now log in to your server and add the contents of the public key to the file .ssh\/authorized_keys2.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>nano ~\/.ssh\/authorized_keys2<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Having a SSH key can be very handy to avoid having to enter your password every&hellip;<\/p>\n","protected":false},"author":1,"featured_media":1987,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[17],"tags":[19,18],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to generate an SSH key - Linux Digest<\/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:\/\/linuxdigest.com\/howto\/how-to-generate-ssh-key\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to generate an SSH key - Linux Digest\" \/>\n<meta property=\"og:description\" content=\"Having a SSH key can be very handy to avoid having to enter your password every&hellip;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/linuxdigest.com\/howto\/how-to-generate-ssh-key\/\" \/>\n<meta property=\"og:site_name\" content=\"Linux Digest\" \/>\n<meta property=\"article:published_time\" content=\"2019-11-16T19:08:17+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-01-24T13:08:44+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/linuxdigest.com\/wp-content\/uploads\/2019\/11\/Generate-SSH-key-1.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"795\" \/>\n\t<meta property=\"og:image:height\" content=\"345\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"The Linux Digest Guy\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"The Linux Digest Guy\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/linuxdigest.com\/howto\/how-to-generate-ssh-key\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/linuxdigest.com\/howto\/how-to-generate-ssh-key\/\"},\"author\":{\"name\":\"The Linux Digest Guy\",\"@id\":\"https:\/\/linuxdigest.com\/#\/schema\/person\/29c97230aa94affab929a88c6a10adb2\"},\"headline\":\"How to generate an SSH key\",\"datePublished\":\"2019-11-16T19:08:17+00:00\",\"dateModified\":\"2021-01-24T13:08:44+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/linuxdigest.com\/howto\/how-to-generate-ssh-key\/\"},\"wordCount\":274,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/linuxdigest.com\/#organization\"},\"keywords\":[\"Command line\",\"SSH\"],\"articleSection\":[\"Linux server\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/linuxdigest.com\/howto\/how-to-generate-ssh-key\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/linuxdigest.com\/howto\/how-to-generate-ssh-key\/\",\"url\":\"https:\/\/linuxdigest.com\/howto\/how-to-generate-ssh-key\/\",\"name\":\"How to generate an SSH key - Linux Digest\",\"isPartOf\":{\"@id\":\"https:\/\/linuxdigest.com\/#website\"},\"datePublished\":\"2019-11-16T19:08:17+00:00\",\"dateModified\":\"2021-01-24T13:08:44+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/linuxdigest.com\/howto\/how-to-generate-ssh-key\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/linuxdigest.com\/howto\/how-to-generate-ssh-key\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/linuxdigest.com\/howto\/how-to-generate-ssh-key\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/linuxdigest.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to generate an SSH key\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/linuxdigest.com\/#website\",\"url\":\"https:\/\/linuxdigest.com\/\",\"name\":\"Linux Digest\",\"description\":\"Linux tutorials for everyone\",\"publisher\":{\"@id\":\"https:\/\/linuxdigest.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/linuxdigest.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/linuxdigest.com\/#organization\",\"name\":\"Linux Digest\",\"url\":\"https:\/\/linuxdigest.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/linuxdigest.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/linuxdigest.com\/wp-content\/uploads\/2019\/11\/logo1.png\",\"contentUrl\":\"https:\/\/linuxdigest.com\/wp-content\/uploads\/2019\/11\/logo1.png\",\"width\":1102,\"height\":170,\"caption\":\"Linux Digest\"},\"image\":{\"@id\":\"https:\/\/linuxdigest.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/linuxdigest.com\/#\/schema\/person\/29c97230aa94affab929a88c6a10adb2\",\"name\":\"The Linux Digest Guy\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/linuxdigest.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/ac6bcf745dec6961360ccf2d2711f26c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/ac6bcf745dec6961360ccf2d2711f26c?s=96&d=mm&r=g\",\"caption\":\"The Linux Digest Guy\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to generate an SSH key - Linux Digest","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:\/\/linuxdigest.com\/howto\/how-to-generate-ssh-key\/","og_locale":"en_US","og_type":"article","og_title":"How to generate an SSH key - Linux Digest","og_description":"Having a SSH key can be very handy to avoid having to enter your password every&hellip;","og_url":"https:\/\/linuxdigest.com\/howto\/how-to-generate-ssh-key\/","og_site_name":"Linux Digest","article_published_time":"2019-11-16T19:08:17+00:00","article_modified_time":"2021-01-24T13:08:44+00:00","og_image":[{"width":795,"height":345,"url":"https:\/\/linuxdigest.com\/wp-content\/uploads\/2019\/11\/Generate-SSH-key-1.jpg","type":"image\/jpeg"}],"author":"The Linux Digest Guy","twitter_card":"summary_large_image","twitter_misc":{"Written by":"The Linux Digest Guy","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/linuxdigest.com\/howto\/how-to-generate-ssh-key\/#article","isPartOf":{"@id":"https:\/\/linuxdigest.com\/howto\/how-to-generate-ssh-key\/"},"author":{"name":"The Linux Digest Guy","@id":"https:\/\/linuxdigest.com\/#\/schema\/person\/29c97230aa94affab929a88c6a10adb2"},"headline":"How to generate an SSH key","datePublished":"2019-11-16T19:08:17+00:00","dateModified":"2021-01-24T13:08:44+00:00","mainEntityOfPage":{"@id":"https:\/\/linuxdigest.com\/howto\/how-to-generate-ssh-key\/"},"wordCount":274,"commentCount":0,"publisher":{"@id":"https:\/\/linuxdigest.com\/#organization"},"keywords":["Command line","SSH"],"articleSection":["Linux server"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/linuxdigest.com\/howto\/how-to-generate-ssh-key\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/linuxdigest.com\/howto\/how-to-generate-ssh-key\/","url":"https:\/\/linuxdigest.com\/howto\/how-to-generate-ssh-key\/","name":"How to generate an SSH key - Linux Digest","isPartOf":{"@id":"https:\/\/linuxdigest.com\/#website"},"datePublished":"2019-11-16T19:08:17+00:00","dateModified":"2021-01-24T13:08:44+00:00","breadcrumb":{"@id":"https:\/\/linuxdigest.com\/howto\/how-to-generate-ssh-key\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/linuxdigest.com\/howto\/how-to-generate-ssh-key\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/linuxdigest.com\/howto\/how-to-generate-ssh-key\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/linuxdigest.com\/"},{"@type":"ListItem","position":2,"name":"How to generate an SSH key"}]},{"@type":"WebSite","@id":"https:\/\/linuxdigest.com\/#website","url":"https:\/\/linuxdigest.com\/","name":"Linux Digest","description":"Linux tutorials for everyone","publisher":{"@id":"https:\/\/linuxdigest.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/linuxdigest.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/linuxdigest.com\/#organization","name":"Linux Digest","url":"https:\/\/linuxdigest.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/linuxdigest.com\/#\/schema\/logo\/image\/","url":"https:\/\/linuxdigest.com\/wp-content\/uploads\/2019\/11\/logo1.png","contentUrl":"https:\/\/linuxdigest.com\/wp-content\/uploads\/2019\/11\/logo1.png","width":1102,"height":170,"caption":"Linux Digest"},"image":{"@id":"https:\/\/linuxdigest.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/linuxdigest.com\/#\/schema\/person\/29c97230aa94affab929a88c6a10adb2","name":"The Linux Digest Guy","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/linuxdigest.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/ac6bcf745dec6961360ccf2d2711f26c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ac6bcf745dec6961360ccf2d2711f26c?s=96&d=mm&r=g","caption":"The Linux Digest Guy"}}]}},"_links":{"self":[{"href":"https:\/\/linuxdigest.com\/wp-json\/wp\/v2\/posts\/1748"}],"collection":[{"href":"https:\/\/linuxdigest.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxdigest.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxdigest.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxdigest.com\/wp-json\/wp\/v2\/comments?post=1748"}],"version-history":[{"count":3,"href":"https:\/\/linuxdigest.com\/wp-json\/wp\/v2\/posts\/1748\/revisions"}],"predecessor-version":[{"id":1988,"href":"https:\/\/linuxdigest.com\/wp-json\/wp\/v2\/posts\/1748\/revisions\/1988"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxdigest.com\/wp-json\/wp\/v2\/media\/1987"}],"wp:attachment":[{"href":"https:\/\/linuxdigest.com\/wp-json\/wp\/v2\/media?parent=1748"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxdigest.com\/wp-json\/wp\/v2\/categories?post=1748"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxdigest.com\/wp-json\/wp\/v2\/tags?post=1748"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}