مرکز آموزش

How to Generate an SSH Key on Linux Print

  • 0

SSH keys are a secure and convenient way to log in to servers without using a password. This guide explains how to generate an SSH key on a Linux system.

Step 1: Open a Terminal

On your Linux system, open a terminal window (Ctrl + Alt + T). All commands in this guide will be run from there.

Step 2: Generate a New SSH Key Pair

On your terminal, run ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

Replace your_email@example.com with your email address 

https://sive.host/titfombe/repository/pkey1.png

Step 3:  Choose a Save Location

You’ll see a prompt like: Enter file in which to save the key (/home/username/.ssh/id_rsa):

https://sive.host/titfombe/repository/pkey2.png

Press Enter to accept the default location (~/.ssh/id_rsa).

Or type a custom filename to create multiple keys.

Step 4: Add a Passphrase (Optional)

You’ll be asked to set a passphrase:

Enter passphrase (empty for no passphrase):
https://sive.host/titfombe/repository/pkey3.png

Press Enter for no passphrase (less secure).

Or enter a strong passphrase for extra protection.

After completion, you’ll have:

 

  • Private key: ~/.ssh/id_rsa (keep safe, never share)

  • Public key: ~/.ssh/id_rsa.pub (this is the one you share)

Step 5: Display Your Public Key

To view and copy your public key, run:  cat ~/.ssh/id_rsa.pub

https://sive.host/titfombe/repository/pkey4.pnghttps://sive.host/titfombe/repository/pkey4.png
Copy the full key string and paste it where needed


آیا این پاسخ به شما کمک کرد؟
Back