Setting Up SSH Keys for HPC Cluster Access

Introduction

This guide walks you through generating and configuring SSH keys to securely access the BGU HPC cluster’s login node, bhn20. For Windows users, refer to MobaXterm guide.

Prerequisites

You must have an SSH client installed on your local machine and accessible from the terminal.

Connecting to bhn20

In this guide, we will connect to the login node, bhn20. Please note that this node is accessible exclusively from the university’s network. To complete any steps that involve bhn20, you must either:

  1. Be connected to the university network via cable or Wi-Fi, or

  2. Have an active connection to the university’s VPN.

Failure to meet these requirements will prevent you from accessing bhn20.

Generate SSH Keys

If you already have an SSH key pair, you can skip to Copying Your Public Key.
MobaXterm is not recommended for generating SSH keys because it uses a separate home directory.

First, open a terminal on your local machine. You can use the Windows Start menu or macOS’s Spotlight to find the "Terminal" application.

Then, execute the following command in your local terminal:

Generate SSH Key
$ ssh-keygen -t ed25519 -N "" -f ~/.ssh/id_ed25519
Generating public/private ed25519 key pair.
Your identification has been saved in C:\Users\<your_windows_user>/.ssh/bgu-hpc
Your public key has been saved in C:\Users\<your_windows_user>/.ssh/bgu-hpc.pub
The key fingerprint is:
SHA256:/N8QgacPP8/IZYrupYOgYVwVUevUH1ObARJc7dkhmx0 <your_windows_user>@<your_windows_user>
The key's randomart image is:
+--[ED25519 256]--+
|        o+ooooo..|
|        .  =.. E+|
|       .  + + Oo=|
|      .. o o = *.|
|   . .  S + . .  |
|    + .  . + .   |
|   . o . .. * o  |
|    .   . .* @   |
|         o=.= +  |
+----[SHA256]-----+

.

Connect to bhn20 and Copy Your Public Key

Next, you’ll connect to the cluster to copy your public key.

  1. Connect to bhn20 using your BGU username:

    $ ssh <your-bgu-username>@bhn20 (1)
    The authenticity of host 'bhn20 (132.72.137.66)' can't be established.
    ED25519 key fingerprint is SHA256:4IV/zfBdrsx8VAkGqd7bV+mFPvTl52KevymdDWn/ToY.
    This key is not known by any other names
    Are you sure you want to continue connecting (yes/no/[fingerprint])?
    1 Substitute <your-bgu-username> with your actual BGU username.
  2. Verify the fingerprint. Type yes and press Enter if it matches the one below:

    SHA256:4IV/zfBdrsx8VAkGqd7bV+mFPvTl52KevymdDWn/ToY
  3. Enter your BGU password when prompted. Note that your password will not be displayed as you type.

Copying the Public Key

Now, let’s add your public key to the cluster’s authorized keys list.

  1. On your local machine, open the public key file ($HOME/.ssh/bgu-hpc.pub) and copy its entire content.

  2. Back in the bhn20 terminal, paste the copied key into the following command, replacing <your_public_key> (but keep the quotes):

    $ echo "<your_public_key>" >> ~/.ssh/authorized_keys

Testing SSH Key Authentication

Finally, let’s test the setup. Open a new local terminal window and run the following command:

$ ssh <your-bgu-username>@bhn20

If everything is configured correctly, you will be logged in without being asked for a password. Congratulations, you’re all set!