How to Generate an SSH Key on Linux

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

  • 0 Bu dökümanı faydalı bulan kullanıcılar:
Bu cevap yeterince yardımcı oldu mu?

İlgili diğer dökümanlar

12 Useful “df” Commands to Check Disk Space in Linux

Useful df Command Examples This article explain a way to get the full information of Linux disk...

How to Disable SELinux

How to Disable SELinux You’ve setup a new system, or installed something new on your Linux...

How to set a Static IP in Ubuntu Linux

How to set a Static IP in Ubuntu LinuxOpen the terminal command line application or ssh into the...

Linux Check Disk Space Command To View System Disk Usage

Linux Check Disk Space Command To View System Disk Usage Linux command to check disk space...