Skip to content
mybox Help Center

Help sections

  • Getting Started
  • Account & Billing
  • Domains & DNS
  • Hosting & Servers
  • Email
  • Security & SSL
  • WordPress & CMS
  • Grow Online
mybox.com All services operational
/

Language

  • English
  • Română
  • mybox panel
  • Webmail
Start free
/
  • Getting Started
  • Account & Billing
  • Domains & DNS
  • Hosting & Servers
  • Email
  • Security & SSL
  • WordPress & CMS
  • Grow Online
  • Help Center
  • mybox.com
  • English
  • Română
All services operational Start free
  1. Help Center
  2. Security & SSL
  3. Account & Password Security
How-to Security & SSL

How do I generate SSH keys on Mac OS?

Updated June 3, 2026 2 min read
On this page
  1. Step 1: Open Terminal
  2. Step 2: Generate the SSH Key Pair
  3. Step 3: Set a Passphrase
  4. Step 4: Verify the Generated Keys
  5. Generated Files
  6. Private Key
  7. Public Key
  8. Display the Public Key
  9. Add the Public Key to the Server
  10. Test the Connection
  11. Security Recommendations
  12. Summary

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.

Step 1: Open Terminal

Open the Terminal application on your Mac.

You can find it in:

Applications → Utilities → Terminal

Step 2: Generate the SSH Key Pair

Run the following command:

ssh-keygen

You will be prompted to choose a location for the key files:

Enter file in which to save the key (/Users/username/.ssh/id_rsa):

Press Enter to use the default location, or specify a custom path.

Step 3: Set a Passphrase

Next, you will be asked to enter a passphrase:

Enter passphrase (empty for no passphrase):

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.

You will then be asked to enter the passphrase again for confirmation.

Step 4: Verify the Generated Keys

After the process is complete, you will see a message similar to:

Your identification has been saved in /Users/username/.ssh/id_rsa.
Your public key has been saved in /Users/username/.ssh/id_rsa.pub.

The key pair will be stored in the ~/.ssh directory.

Generated Files

Two files will be created:

File Description
id_rsa Private key
id_rsa.pub Public key

Private Key

~/.ssh/id_rsa

The private key should remain on your computer and should never be shared.

Public Key

~/.ssh/id_rsa.pub

The public key is the file that should be added to the server.

Display the Public Key

To view the contents of the public key, run:

cat ~/.ssh/id_rsa.pub

Copy the entire output.

Add the Public Key to the Server

Paste the public key into the following file on the server:

~/.ssh/authorized_keys

If the file does not exist, create it and add the key on a new line.

Test the Connection

After adding the public key to the server, connect using SSH:

ssh username@server-address

If the configuration is correct, the server will authenticate you using your SSH key.

Security Recommendations

  • Never share your private key.
  • Store your private key only on trusted devices.
  • Protect the key with a strong passphrase whenever possible.
  • Remove unused public keys from the server regularly.

Summary

Generating SSH keys on macOS requires running the ssh-keygen command in Terminal. This creates a private key (id_rsa) and a public key (id_rsa.pub) in the ~/.ssh directory. The public key should be added to the server’s authorized_keys file, while the private key should be kept secure and never shared.

Was this article helpful?

Didn't find an answer?

Our support team is here for you 24/7 – write to us and we will help you sort it out.

Helpdesk 24/7 Open a ticket in the mybox panel mybox panel Log in and manage your services

On this page

  1. Step 1: Open Terminal
  2. Step 2: Generate the SSH Key Pair
  3. Step 3: Set a Passphrase
  4. Step 4: Verify the Generated Keys
  5. Generated Files
  6. Private Key
  7. Public Key
  8. Display the Public Key
  9. Add the Public Key to the Server
  10. Test the Connection
  11. Security Recommendations
  12. Summary

Related articles

All in Account & Password Security
How-to Account & Password Security FTP client – How to take care of security? When using FTP clients to manage your website files, it is important to follow security best practices to protect your hosting account… 2 min read How-to Account & Login Management How do I set up 2FA in the mybox panel? Two-factor authentication (2FA) adds a second verification step when logging in to the mybox panel. After entering your password, the panel asks… 1 min read How-to WebMail mail.mybox.com How do I set up two-step verification in Webmail? Security is a priority today, and two-step verification, which requires not only knowing and providing a password, but also a one-time code,… 2 min read
mybox

Modular web hosting – free out of the box, modular to grow.

Help sections

  • Getting Started
  • Account & Billing
  • Domains & DNS
  • Hosting & Servers
  • Email
  • Security & SSL
  • WordPress & CMS
  • Grow Online

mybox

  • mybox.com
  • mybox panel
  • Webmail
  • Helpdesk 24/7
© 2026 mybox 1,680 articles