{"id":375,"date":"2025-12-18T05:53:02","date_gmt":"2025-12-18T04:53:02","guid":{"rendered":"https:\/\/mybox.com\/help\/?post_type=manual_kb&#038;p=375"},"modified":"2026-06-03T05:56:59","modified_gmt":"2026-06-03T03:56:59","slug":"how-do-i-generate-ssh-keys-on-mac-os","status":"publish","type":"manual_kb","link":"https:\/\/mybox.com\/help\/en\/knowledgebase\/how-do-i-generate-ssh-keys-on-mac-os\/","title":{"rendered":"How do I generate SSH keys on Mac OS?"},"content":{"rendered":"\n<div class=\"translation-block translation-block-merged\">\n<p class=\"wp-block-paragraph\">SSH keys provide a secure way to authenticate 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-mac-os\/#Step_1_Open_Terminal\" >Step 1: Open 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-mac-os\/#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-mac-os\/#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-mac-os\/#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-mac-os\/#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-mac-os\/#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-mac-os\/#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-mac-os\/#Display_the_Public_Key\" >Display the Public Key<\/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-mac-os\/#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-10\" href=\"https:\/\/mybox.com\/help\/en\/knowledgebase\/how-do-i-generate-ssh-keys-on-mac-os\/#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-11\" href=\"https:\/\/mybox.com\/help\/en\/knowledgebase\/how-do-i-generate-ssh-keys-on-mac-os\/#Security_Recommendations\" >Security Recommendations<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/mybox.com\/help\/en\/knowledgebase\/how-do-i-generate-ssh-keys-on-mac-os\/#Summary\" >Summary<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_1_Open_Terminal\"><\/span>Step 1: Open Terminal<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Open the <strong>Terminal<\/strong> application on your Mac.<\/p>\n\n\n\n<\/div>\n\n<div id=\"mybox-2403263700\" 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\">You can find it in:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Applications \u2192 Utilities \u2192 Terminal<\/strong><\/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<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\">You will be prompted 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 (\/Users\/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\">Next, 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 is optional, but it adds an extra layer of protection to your private key. For better security, use a strong and memorable passphrase.<\/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 message similar to:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Your identification has been saved in \/Users\/username\/.ssh\/id_rsa.<br>Your public key has been saved in \/Users\/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 should never be shared.<\/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=\"Display_the_Public_Key\"><\/span>Display the Public Key<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To view the contents of the public key, run:<\/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.<\/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\">Paste the public key into the following file on the server:<\/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\">If the file does not exist, create it and add the key on a new line.<\/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\">After adding the public key 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 the configuration is correct, the server will authenticate you using your SSH key.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Security_Recommendations\"><\/span>Security Recommendations<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Never share your private key.<\/li>\n\n\n\n<li>Store your private key only on trusted devices.<\/li>\n\n\n\n<li>Protect the key with a strong passphrase whenever possible.<\/li>\n\n\n\n<li>Remove unused public keys from the server regularly.<\/li>\n<\/ul>\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 macOS requires running the <code>ssh-keygen<\/code> command in Terminal. 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\n\n\n<p class=\"wp-block-paragraph\"><\/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":[3419,3420,3421,3422,751,952,953,3372,3413,3414,3415,3416,3417,3418],"class_list":["post-375","manual_kb","type-manual_kb","status-publish","format-standard","hentry","manualknowledgebasecat-hosting","manualknowledgebasecat-ssh","manual_kb_tag-macos-ssh","manual_kb_tag-mac-terminal","manual_kb_tag-ssh-key-pair","manual_kb_tag-public-key-file","manual_kb_tag-ssh-keys","manual_kb_tag-public-key","manual_kb_tag-private-key","manual_kb_tag-private-key-file","manual_kb_tag-generate-ssh-keys","manual_kb_tag-ssh-keygen","manual_kb_tag-id_rsa","manual_kb_tag-id_rsa-pub","manual_kb_tag-authorized_keys","manual_kb_tag-macos-terminal"],"_links":{"self":[{"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/manual_kb\/375","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\/375\/revisions"}],"predecessor-version":[{"id":9517,"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/manual_kb\/375\/revisions\/9517"}],"wp:attachment":[{"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/media?parent=375"}],"wp:term":[{"taxonomy":"manualknowledgebasecat","embeddable":true,"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/manualknowledgebasecat?post=375"},{"taxonomy":"manual_kb_tag","embeddable":true,"href":"https:\/\/mybox.com\/help\/en\/wp-json\/wp\/v2\/manual_kb_tag?post=375"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}