0
0
Linux CLIscripting~15 mins

SSH key generation (ssh-keygen) in Linux CLI - Mini Project: Build & Apply

Choose your learning style9 modes available
SSH Key Generation with ssh-keygen
📖 Scenario: You want to securely connect to a remote server without typing your password every time. To do this, you will create an SSH key pair on your local machine.
🎯 Goal: Learn how to generate an SSH key pair using the ssh-keygen command and display the public key.
📋 What You'll Learn
Use the ssh-keygen command to create an SSH key pair
Specify the key type as RSA
Save the key with the filename my_ssh_key
Do not use a passphrase (empty passphrase)
Display the contents of the public key file
💡 Why This Matters
🌍 Real World
SSH keys are used to securely connect to servers without typing passwords every time, making remote work faster and safer.
💼 Career
System administrators, developers, and IT professionals use SSH keys daily to manage servers and deploy applications securely.
Progress0 / 4 steps
1
Create an SSH key pair
Run the ssh-keygen command with the options to generate an RSA key and save it as my_ssh_key. When prompted for a passphrase, press Enter twice to leave it empty.
Linux CLI
Need a hint?

The -t option sets the key type, -f sets the filename, and -N sets the passphrase.

2
Verify the key files exist
Use the ls command to list the files starting with my_ssh_key in the current directory.
Linux CLI
Need a hint?

The public key file will have the same name with .pub appended.

3
Display the public key content
Use the cat command to show the contents of the public key file my_ssh_key.pub.
Linux CLI
Need a hint?

The public key is a long string starting with ssh-rsa.

4
Show the public key output
Run the full script to generate the key, list the files, and display the public key content. The output should show the public key starting with ssh-rsa.
Linux CLI
Need a hint?

The output should include a line starting with ssh-rsa followed by a long string.