Who This Is For (And What Problem We’re Fixing)
If you’re logging into a Debian 10 server using passwords, you’re doing it the hard way.
SSH keys are easier once set up, and much safer than typing passwords all day.
This guide walks you through creating SSH keys on your Debian 10 client (your own computer) and explains the prompts so you don’t accidentally break something important.
We’ll stick closely to the actual behavior of the ssh-keygen command and keep it practical.
Before You Start: What You Actually Need
You don’t need anything fancy to follow this:
- A Debian 10 system (this can be your laptop, desktop, or another server) where you’ll create the SSH keys.
- Access to a terminal on that Debian machine.
A couple of safety notes before we touch anything:
- If you already use SSH keys on this machine, be careful not to overwrite them unless you know what you’re doing.
- We’ll talk about the overwrite warning when it shows up, because saying “yes” there can lock you out of places that still use your old key.
Step 1: Generate Your SSH Key Pair with ssh-keygen
First, open a terminal on your Debian 10 machine.
Run this command:
ssh-keygen
This command creates a pair of files:
– One is your private key (keep it secret).
– One is your public key (you share this with servers).
By default, ssh-keygen creates a 2048-bit RSA key pair.
That’s secure enough for most uses.
If you want a bigger key, you could add the -b 4096 flag, but the basic source example sticks with the default.
After you run ssh-keygen, you’ll see something like:
Generating public/private rsa key pair.
Enter file in which to save the key (/your_home/.ssh/id_rsa):
Let’s walk through what to do at each of these prompts.
Step 2: Choose Where to Save the Key (or Just Hit Enter)
At this prompt:
Enter file in which to save the key (/your_home/.ssh/id_rsa):
you have two choices:
- Fast and typical: Just press Enter.
- Your key pair will be stored in:
- Private key:
/your_home/.ssh/id_rsa - Public key:
/your_home/.ssh/id_rsa.pub
- Private key:
- This is what most people should do.
- Custom location (only if you have a reason): Type a different path and press Enter.
- Example:
/your_home/.ssh/my_project_key - Then you’ll end up with:
- Private key:
/your_home/.ssh/my_project_key - Public key:
/your_home/.ssh/my_project_key.pub
- Private key:
If you don’t know why you’d need a custom name, stick with the default by pressing Enter.
It keeps life simple, and most tools expect that default path.
Step 3: Avoid Accidentally Overwriting an Existing Key
If this is your first time running ssh-keygen on this machine, you probably won’t see this.
But if you created keys before, you might get this warning:
/home/your_home/.ssh/id_rsa already exists.
Overwrite (y/n)?
This is serious.
If you type y and press Enter:
- Your existing private key file will be replaced.
- Any server that still expects your old public key will no longer recognize you.
- If you don’t have another way in, you can lock yourself out of servers.
This is a destructive action and cannot be reversed.
Once the old key is overwritten, it’s gone.
So what should you do?
- If you don’t want to lose the old key:
- Type n and press Enter.
- Then run
ssh-keygenagain, but this time give it a different file name when it asks where to save. - If you are sure you no longer need the old key:
- Type y and press Enter.
- Just remember: any server using the old key will stop accepting it.
If you’re unsure, treat the existing key like a backup you might need later.
Better to keep it until you know you’re done with those servers.
Step 4: Set a Passphrase (Why It Matters)
Next, you’ll see this prompt:
Enter passphrase (empty for no passphrase):
Here you can choose to:
- Set a passphrase (recommended).
- Leave it empty (press Enter twice) if you really want no passphrase.
A passphrase is like a password that protects your private key file.
Even if someone copies that file from your machine, they can’t use it easily without the passphrase.
The source strongly recommends using a secure passphrase.
That extra layer of security helps prevent unauthorized logins.
Things to keep in mind:
- Pick something you can remember but others can’t guess.
- You’ll be asked for this passphrase when you use the key to log in.
After you type your passphrase, you’ll be asked to confirm it once more.
Then ssh-keygen will finish generating the keys.
Step 5: Confirm Your Key Files Were Created
Once everything is done, you’ll see output like this:
Your identification has been saved in /your_home/.ssh/id_rsa.
Your public key has been saved in /your_home/.ssh/id_rsa.pub.
The key fingerprint is:
a9:49:2e:2a:5e:33:3e:a9:de:4e:77:11:58:b6:90...
That means:
- Your private key is in:
/your_home/.ssh/id_rsa - Your public key is in:
/your_home/.ssh/id_rsa.pub
If you used a custom filename, the paths will match what you typed.
The “fingerprint” is just a short identifier for the key — useful when you need to compare or verify keys.
To double-check the files exist, you can list them:
ls -l ~/.ssh
You should see your key files there.
The private key stays on your machine; the public key (.pub) is what you’ll copy to your servers.
Safe Habits After Generating SSH Keys
Even though we only covered key creation here, a few safety habits are worth repeating:
- Never share your private key file (
id_rsaor whatever name you chose). - Only the
.pubfile is meant to be shared. - Be cautious with overwrites.
- That
Overwrite (y/n)?prompt is your last chance to keep an old, working key. - Use a passphrase if possible.
- It protects you if someone grabs a copy of your private key.
From here, the usual next step is to copy your public key to a server so you can log in using key-based authentication instead of passwords.
The source mentions a separate tutorial for fully configuring SSH key-based authentication on a Linux server — that’s where you’d go next.
If this saved you time, bookmark CrushEdge for more fixes.
No Comments