Generate and use SSH key

What Is SSH and how can it benefit you? #

Secure Shell (SSH) is a protocol that establishes a secure connection between your local computer and a remote system. This connection allows you to manage the VM remotely without compromising security.

Access is achieved by using a key. Your private key must remain on your host, and a public key file (.pub) that is not secret must be copied to the remote system to enable your private key to be used for access.

SSH Keys types #

An SSH connection uses two types of keys:

  • Private Key: is stored on your local computer and should not be shared. Other users will be able to access your remote system without your permission if they gain access to your private key.
  • Public Key: A non-sensitive file (.pub file extension) that you share with remote systems. It pairs with your private key to authenticate connections. Upload and save it to your myDelska Cloud Platform profile for easy copying and use when deploying a new Virtual Machine.

Why do I need an SSH Key? #

An SSH key provides stronger protection than a password. When you share your public key with the VM, only your private key can verify access to the system, significantly reducing the risk of unauthorized entry.

How to create SSH Key #

To create your own SSH key, you can use any tool you know and have available to create SSH keys or connect to a VM remotely.

SSH Keys on Windows, macOS, and Linux #

Starting from Windows 10, a built-in OpenSSH client is available, allowing users to generate and manage SSH keys without additional software. However, if you use an older version of Windows or prefer an alternative tool, you can use PuTTY. Below, we provide instructions for both methods and guidance for macOS and Linux users.

SSH Key Generation and Connection on Windows #

Windows 10 and 11 provide built-in functionality for generating SSH keys using OpenSSH. PuTTY or if your version of Windows is below 10, please see below.

  1. Open the Terminal (PowerShell or Command Prompt)
  2. Enter the ssh-keygen command to generate a key.
ssh-keygen
  1. Choose the Save Location. By default, the keys are stored in the (C:\Users\Your_Username/.ssh/id_rsa).
  2. Set a Passphrase or leave it empty.
  3. Keys have been generated.
  4. To get a public key, enter the command:
  • 6.1. Command Prompt
type C:\Users\username\.ssh\id_rsa.pub
  • 6.2. PowerShell
cat ~/.ssh/id_rsa.pub
Example: >ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCuser@hostname
  1. To add the generated SSH key to myDelska profile, copy the id_rsa.pub public key content to the clipboard.
  • Click on the circle (Users) in the top right corner and select SSH keys.
  • Click Add SSH key and Paste key here.
  • Enter a descriptive key name to identify it among multiple keys quickly, then click Add SSH key.
  1. The key has been successfully saved.

How do I connect to the VM from the local computer? #

Open a terminal and run the command:

ssh username@<public_IP_address_of_VM>

How to Create SSH Keys using PuTTY? #

  1. It is necessary to install the client for remote access protocols - PuTTY, to generate an SSH key.
  2. Download and install PuTTY. Download PuTTY here: https://www.chiark.greenend.org.uk/~sgtatham/putty/, or via the Microsoft Store.
  3. After the installation is complete, open PuTTYgen from the START menu or by pressing Windows + R and typing in the command:
puttygen
  1. Select the ECDSA key type and click Generate. Your unique SSH key has been generated.
  2. The generated SSH key will appear in the textbox. Copy it to your myDelska profile by following the steps:
  • Click on the circle (Users) in the top right corner and select SSH keys.
  • Click Add SSH key and Paste key here.
  • Enter a descriptive key name to easily identify it among multiple keys, then click Add SSH key.
  • The key will be saved.
  1. Click the Save Private Key button and choose a safe place to save the key. Your key can have any name you choose, along with any extension .PPK (PuTTY private key) has automatically been applied.

Use Putty:

  1. Open PuTTY.
  2. Enter the VM’s IP address in Session > Host Name (IP Address).
  3. Assign a name in Saved Sessions.
  4. Navigate to Connection > Data > Auto-login.
  5. Enter the root username.
  6. Go to Connection > SSH > Auth > Credentials.
  7. Under “Private key file for authentication”, click Browse and select the saved .ppk file.
  8. Return to the Session section.
  9. Click Save.
  10. Click Open to establish the SSH connection.

SSH key creation and connection on MacOS and Linux OS #

  1. To generate a 2048-bit RSA key pair, run the standard OpenSSH toolset on your computer.
  2. Enter the following command:
ssh-keygen
  1. Choose a location to save the key. By default, keys are stored in ~/.ssh/ with filenames id_rsa (private key) and id_rsa.pub (public key).
Using the default locations allows your SSH client to find your SSH keys when authenticating automatically, so we recommend accepting them by pressing ENTER.
  1. Enter a Passphrase (or leave it empty) and confirm it.
  2. The key has been generated.
Generating public/private RSA key pair.
Enter the file in which to save the key (/home/user/.ssh/id_rsa): 
Created directory '/home/user/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/user/.ssh/id_rsa
Your public key has been saved in /home/user/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:n5atjy1iEhEH+TK/SL73x1YDg0qfmsdVoxhfRUKphyU user@hostname
The key's randomart image is:
+---[RSA 3072]----+
|      .o     .oo.|
|      o .   E o..|
|       +   . = . |
|      + o o = =  |
|       *So = B . |
|      o o.+++ o  |
|     o o ==o.. . |
|      + B.+++    |
|      .= ++=o    |
+----[SHA256]-----+
  1. To display the public key, enter:
cat ~/.ssh/id_rsa.pub
Example: >ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCluser@hostname
  1. To add the generated SSH key to your: myDelska profile.
  • Click on the circle (Users) in the top right corner and select SSH keys.
  • Click Add SSH key and paste the copied key.
  • Enter a descriptive key name to easily identify it among multiple keys, then click Add SSH key.
  1. The key has been successfully saved.

Connect to the VM from your local computer #

To establish an SSH connection to your VM, run the following command:

ssh username@<public_IP_address_of_VM>