Skip to content

Generating a Public-Private Key Pair on Your Laptop


Intro

You don't whisper a password through your letter box to get into your house, most people use a key. We will use the same thing for getting access to the student server using SSH protocol.

1. Generate the Key Pair

Open the terminal on your laptop and run the following command:

ssh-keygen -t ed25519 -C "your_email@example.com"
  • 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 student.computing.dcu.ie 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

For example, here is the output from my laptop. This Public Key needs to be copied across to termcast.

cat ~/.ssh/id_ed25519.pub
ssh-ed25519 AAAAC3NzaC1lZDI1NTEDDEEDIODGjcvqJ+0YNInUpNz3UrI5PovlfaX08XhZ/mrRkEop your_email@dcu.ie

4. Log into termcast.computing.dcu.ie and copy YOUR public key to your student.computing.dcu.ie account

  • Copy all the output from ssh-ed25519 to the email, and add it to the next command.
  • NOTE: Do not delete any existing entries in the ~/.ssh/authorized_keys file
  • Now go to termcast.computing.dcu.ie where you can install the keys with the following command
echo "INSERT YOUR KEY HERE - output from the cat ~/.ssh/id_ed25519.pub command" | tee -a ~/.ssh/authorized_keys

For Example[this is my key]:

echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTEDDEEDIODGjcvqJ+0YNInUpNz3UrI5PovlfaX08XhZ/mrRkEop your_email@dcu.ie" | tee -a ~/.ssh/authorized_keys

5. Log in via SSH

Try logging in to the server using SSH:

ssh username@student.computing.dcu.ie

Replace "username" with your actual username.

6. YouTube video example

For a visual guide, you can watch this video tutorial on YouTube.