📖 Scenario: You want to securely connect to a remote server without typing your password every time. Key-based authentication lets you do this by using a pair of keys: a private key on your computer and a public key on the server.This project will guide you through creating a key pair, copying the public key to the server, and testing the connection.
🎯 Goal: Set up key-based SSH authentication to a remote server so you can log in without a password.
📋 What You'll Learn
Create an SSH key pair with ssh-keygen
Copy the public key to the remote server using ssh-copy-id
Test the SSH connection without a password prompt
💡 Why This Matters
🌍 Real World
Key-based authentication is used daily by system administrators and developers to securely access servers without typing passwords.
💼 Career
Knowing how to set up SSH keys is essential for roles in IT support, DevOps, cloud engineering, and cybersecurity.
Progress0 / 4 steps
1
Generate SSH key pair
Use the command ssh-keygen -t rsa -b 2048 -f ~/.ssh/id_rsa -N "" to create an RSA key pair with no passphrase.
Linux CLI
Hint
This command creates a 2048-bit RSA key pair without a password. The private key is saved as ~/.ssh/id_rsa and the public key as ~/.ssh/id_rsa.pub.
2
Copy public key to remote server
Use the command ssh-copy-id -i ~/.ssh/id_rsa.pub user@remote_host to copy your public key to the remote server. Replace user and remote_host with the actual username and server address.
Linux CLI
Hint
This command copies your public key to the remote server's ~/.ssh/authorized_keys file, enabling key-based login.
3
Test SSH connection without password
Use the command ssh user@remote_host to connect to the remote server. You should not be asked for a password.
Linux CLI
Hint
If set up correctly, this command logs you in without asking for a password.
4
Display success message
After connecting, run echo "Login successful without password" on the remote server to confirm key-based authentication works.
Linux CLI
Hint
This message confirms you logged in without typing a password.
Practice
(1/5)
1. What is the main purpose of key-based authentication in SSH?
easy
A. To encrypt files on the local computer
B. To allow secure login without typing a password every time
C. To speed up the internet connection
D. To create a backup of the server data
Solution
Step 1: Understand key-based authentication
Key-based authentication uses a pair of keys to allow login without passwords.
Step 2: Identify the main benefit
This method lets users connect securely without typing passwords each time.
Final Answer:
To allow secure login without typing a password every time -> Option B