Generating a Public-Private Key Pair on Your Laptop (Linux / MAC)
Intro
You don't whisper a password through your letter box to get into your house, most people use a key.
1. Generate the Key Pair
Open the terminal on your laptop and run the following command:
ssh-keygen -t ed25519 -C "your_email@mail.dcu.ie"
- ssh-keygen: Generates a new SSH key.
- -t ed25519: ECDSA (using a strong curve like secp384r1 or secp521r1): Another excellent ECC-based option.
- -C "your_email@mail.dcu.ie": Adds a label with your email address.
2. Follow the Prompts
You will be prompted for the following:
File location: Press Enter to accept the default location. Passphrase: Optionally enter a passphrase for added security.
Example:
eUser2@student:~# ssh-keygen -t ed25519 -C "student001@mail.dcu.ie"
Generating public/private ed25519 key pair.
Enter file in which to save the key (/home/student/.ssh/id_ed25519):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/student/.ssh/id_ed25519
Your public key has been saved in /home/student/.ssh/id_ed25519.pub
3. Copy the Public Key
Once this is complete, you will need to copy your public key to the destination server server:
- Output the contents of the public key just created using the following command "cat /home/student/.ssh/id_ed25519.pub"
cat ~/.ssh/id_ed25519.pub