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 Linux?

Updated June 3, 2026 2 min read
On this page
  1. Step 1: Open a 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. Add the Public Key to the Server
  9. Test the Connection
  10. Summary

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.

Step 1: Open a Terminal

Launch a terminal application on your Linux system.

Step 2: Generate the SSH Key Pair

Run the following command:

ssh-keygen

The system will prompt you to choose a location for the key files:

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

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

Step 3: Set a Passphrase

You will be asked to enter a passphrase:

Enter passphrase (empty for no passphrase):

A passphrase adds an extra layer of security to your private key. While optional, using a strong passphrase is recommended.

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 confirmation similar to:

Your identification has been saved in /home/username/.ssh/id_rsa.
Your public key has been saved in /home/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 must never be shared with anyone.

Public Key

~/.ssh/id_rsa.pub

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

Add the Public Key to the Server

To enable SSH key authentication, copy the contents of the public key file and add it to:

~/.ssh/authorized_keys

on the server.

You can view the public key using:

cat ~/.ssh/id_rsa.pub

Copy the entire output and paste it into the server’s authorized_keys file.

Test the Connection

Once the public key has been added to the server, connect using SSH:

ssh username@server-address

If everything is configured correctly, the server will authenticate using your SSH key.

Summary

Generating SSH keys on Linux requires running the ssh-keygen command. 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 a 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. Add the Public Key to the Server
  9. Test the Connection
  10. 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