{"id":373,"date":"2025-12-18T05:52:12","date_gmt":"2025-12-18T04:52:12","guid":{"rendered":"https:\/\/mybox.com\/help\/?post_type=manual_kb&#038;p=373"},"modified":"2026-06-03T05:55:57","modified_gmt":"2026-06-03T03:55:57","slug":"how-do-i-generate-ssh-keys-on-linux","status":"publish","type":"manual_kb","link":"https:\/\/mybox.com\/help\/en\/knowledgebase\/how-do-i-generate-ssh-keys-on-linux\/","title":{"rendered":"How do I generate SSH keys on Linux?"},"content":{"rendered":"\n<div class=\"translation-block translation-block-merged\">\n<p class=\"wp-block-paragraph\">SSH keys allow you to authenticate securely when connecting to a server via SSH. A key pair consists of a private key, which remains on your device, and a public key, which is added to the server.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_86 ez-toc-wrap-left counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/mybox.com\/help\/en\/knowledgebase\/how-do-i-generate-ssh-keys-on-linux\/#Step_1_Open_a_Terminal\" >Step 1: Open a Terminal<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/mybox.com\/help\/en\/knowledgebase\/how-do-i-generate-ssh-keys-on-linux\/#Step_2_Generate_the_SSH_Key_Pair\" >Step 2: Generate the SSH Key Pair<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/mybox.com\/help\/en\/knowledgebase\/how-do-i-generate-ssh-keys-on-linux\/#Step_3_Set_a_Passphrase\" >Step 3: Set a Passphrase<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/mybox.com\/help\/en\/knowledgebase\/how-do-i-generate-ssh-keys-on-linux\/#Step_4_Verify_the_Generated_Keys\" >Step 4: Verify the Generated Keys<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/mybox.com\/help\/en\/knowledgebase\/how-do-i-generate-ssh-keys-on-linux\/#Generated_Files\" >Generated Files<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/mybox.com\/help\/en\/knowledgebase\/how-do-i-generate-ssh-keys-on-linux\/#Private_Key\" >Private Key<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/mybox.com\/help\/en\/knowledgebase\/how-do-i-generate-ssh-keys-on-linux\/#Public_Key\" >Public Key<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/mybox.com\/help\/en\/knowledgebase\/how-do-i-generate-ssh-keys-on-linux\/#Add_the_Public_Key_to_the_Server\" >Add the Public Key to the Server<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/mybox.com\/help\/en\/knowledgebase\/how-do-i-generate-ssh-keys-on-linux\/#Test_the_Connection\" >Test the Connection<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/mybox.com\/help\/en\/knowledgebase\/how-do-i-generate-ssh-keys-on-linux\/#Summary\" >Summary<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_1_Open_a_Terminal\"><\/span>Step 1: Open a Terminal<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Launch a terminal application on your Linux system.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_2_Generate_the_SSH_Key_Pair\"><\/span>Step 2: Generate the SSH Key Pair<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<\/div>\n\n<div id=\"mybox-4129974345\" class=\"mybox-content mybox-entity-placement\"><div class=\"early-access-banner-inpost\">\r\n  <div class=\"banner-left-inpost\">\r\n    <div class=\"icon-box-inpost\">\r\n      <img decoding=\"async\" src=\"https:\/\/mybox.com\/help\/wp-content\/uploads\/2026\/02\/square-info-icon.svg\" alt=\"Info\">\r\n    <\/div>\r\n    <div class=\"text-box-inpost\">\r\n      <span class=\"label-inpost\"><span class=\"translation-block translation-block-banner-text\">Early access<\/span><\/span>\r\n      <h4><span class=\"translation-block translation-block-banner-text\">Still need help?<\/span><\/h4>\r\n      <p><span class=\"translation-block translation-block-banner-text\">Contact our customer service team.<\/span><\/p>\r\n    <\/div>\r\n  <\/div>\r\n\r\n  <div class=\"banner-right-inpost\">\r\n    <a href=\"https:\/\/panel.mybox.com\/helpdesk2\/v\/list\/\" class=\"banner-button-inpost\"><span class=\"translation-block translation-block-banner-text\">Message us<\/span><\/a>\r\n  <\/div>\r\n<\/div><\/div>\n\n<div class=\"translation-block translation-block-merged\"><p class=\"wp-block-paragraph\">Run the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ssh-keygen<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The system will prompt you to choose a location for the key files:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Enter file in which to save the key (\/home\/username\/.ssh\/id_rsa):<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Press <strong>Enter<\/strong> to use the default location, or specify a custom path.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_3_Set_a_Passphrase\"><\/span>Step 3: Set a Passphrase<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">You will be asked to enter a passphrase:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Enter passphrase (empty for no passphrase):<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">A passphrase adds an extra layer of security to your private key. While optional, using a strong passphrase is recommended.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You will then be asked to enter the passphrase again for confirmation.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_4_Verify_the_Generated_Keys\"><\/span>Step 4: Verify the Generated Keys<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">After the process is complete, you will see a confirmation similar to:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Your identification has been saved in \/home\/username\/.ssh\/id_rsa.<br>Your public key has been saved in \/home\/username\/.ssh\/id_rsa.pub.<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The key pair will be stored in the <code>~\/.ssh<\/code> directory.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Generated_Files\"><\/span>Generated Files<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Two files will be created:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>File<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>id_rsa<\/code><\/td><td>Private key<\/td><\/tr><tr><td><code>id_rsa.pub<\/code><\/td><td>Public key<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Private_Key\"><\/span>Private Key<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>~\/.ssh\/id_rsa<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The private key should remain on your computer and must never be shared with anyone.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Public_Key\"><\/span>Public Key<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>~\/.ssh\/id_rsa.pub<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The public key is the file that should be added to the server.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Add_the_Public_Key_to_the_Server\"><\/span>Add the Public Key to the Server<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To enable SSH key authentication, copy the contents of the public key file and add it to:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~\/.ssh\/authorized_keys<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">on the server.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can view the public key using:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cat ~\/.ssh\/id_rsa.pub<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Copy the entire output and paste it into the server&#8217;s <code>authorized_keys<\/code> file.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Test_the_Connection\"><\/span>Test the Connection<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Once the public key has been added to the server, connect using SSH:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ssh username@server-address<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If everything is configured correctly, the server will authenticate using your SSH key.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Summary\"><\/span>Summary<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Generating SSH keys on Linux requires running the <code>ssh-keygen<\/code> command. This creates a private key (<code>id_rsa<\/code>) and a public key (<code>id_rsa.pub<\/code>) in the <code>~\/.ssh<\/code> directory. The public key should be added to the server&#8217;s <code>authorized_keys<\/code> file, while the private key should be kept secure and never shared.<\/p>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"template":"","format":"standard","manualknowledgebasecat":[25,54],"manual_kb_tag":[3423,3424,3425,3426,3427,3428,3429,3430,3431,3432,751,3433,752,3434,952,953,3413,3414],"class_list":["post-373","manual_kb","type-manual_kb","status-publish","format-standard","hentry","manualknowledgebasecat-hosting","manualknowledgebasecat-ssh","manual_kb_tag-sshkeygen","manual_kb_tag-linux-ssh-keys","manual_kb_tag-linux-ssh","manual_kb_tag-private-key-security","manual_kb_tag-authorized-keys-file","manual_kb_tag-id-rsa-key","manual_kb_tag-id-rsa-public-key","manual_kb_tag-rsa-key-pair","manual_kb_tag-ssh-key-generation","manual_kb_tag-authorized-keys","manual_kb_tag-ssh-keys","manual_kb_tag-passphrase-security","manual_kb_tag-public-key-authentication","manual_kb_tag-id-rsa-file","manual_kb_tag-public-key","manual_kb_tag-private-key","manual_kb_tag-generate-ssh-keys","manual_kb_tag-ssh-keygen"],"_links":{"self":[{"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/manual_kb\/373","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/manual_kb"}],"about":[{"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/types\/manual_kb"}],"author":[{"embeddable":true,"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/users\/1"}],"version-history":[{"count":1,"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/manual_kb\/373\/revisions"}],"predecessor-version":[{"id":9516,"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/manual_kb\/373\/revisions\/9516"}],"wp:attachment":[{"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/media?parent=373"}],"wp:term":[{"taxonomy":"manualknowledgebasecat","embeddable":true,"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/manualknowledgebasecat?post=373"},{"taxonomy":"manual_kb_tag","embeddable":true,"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/manual_kb_tag?post=373"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}