Knowledge Base

How to Create SSH Keys

Last modified: October 17, 2022

This article will cover how to create SSH keys for Mac, Windows, and Linux. Once you create your key, you can then add your public key to your my.pressable.com account to access SSH without needing to enter a password (more info here).

Generate SSH Key with MacOS

Public key type: ecdsa-sha2-nistp256 keys of 256 bits

You can generate your SSH key from macOS terminal by following the steps below:

  • Open Terminal
  • Run this command: ssh-keygen -t rsa

When you execute the command, the ssh-keygen utility prompts you to enter the name of the file you want the key to be stored in. The name of the key can be entered without any extension like for ex. id_rsa_public_key.

Type in a passphrase when prompted. You can hit the ENTER key to accept the default (empty for no passphrase). However, it is recommended to always use a passphrase when generating your public key for security reasons.

Enter the passphrase for the second time to continue, the terminal will generate the key pair automatically.

To see the generated key files you can run ls command to see a list of files inside the directory.

Note: A pair of keys (public and private) will be generated and saved in the directory where the command was initiated, both files will have identical names. However, you can differentiate both files by looking out for the key with .pub extension for ex. id_rsa_public_key.pub

To view the content of the key file from terminal, run this command cat id_rsa.public_key.pub the public key should look similar to this:

The content of the file can be copied to the clipboard by running this command: pbcopy < ~/.ssh/id_rsa.public_key.pub

For security reasons, only the following key types and lengths are allowed

  • ssh-rsa keys from 2048 to 16384 bits
  • ecdsa-sha2-nistp256 keys of 256 bits
  • ssh-ed25519 keys of 256 bits

Generate SSH Key with Windows

To generate your SSH keys on Windows follow the steps below:

  • Open PowerShell or cmd prompt on your client
  • Run this command: ssh-keygen
    The algorithms DSA, RSA, ECDSA, or Ed25519 can be specified. If no algorithm is specified, RSA is used.
    Run command  ssh-keygen -t ecdsa to generate a ecdsa-sha2-nistp256 keys of 256 bits
  • The output from the command should display the following with varsh replaced by your username:
  • You can press Enter to accept the default, or specify a path and filename where you would like your keys to be generated. At this point, you’ll be prompted to use a passphrase to encrypt your private key files. It is recommended to use a highly secure passphrase. This passphrase works with the key file to provide two-factor authentication.
  • Now you have a public/private key pair in the location specified. The .pub files are public keys, and files without an extension are private keys:
  • To view the content of the key file from the PowerShell, run this command Get-Content id_rsa.pub
    The public key should look similar to this:

For security reasons, only the following key types and lengths are allowed

  • ssh-rsa keys from 2048 to 16384 bits
  • ecdsa-sha2-nistp256 keys of 256 bits
  • ssh-ed25519 keys of 256 bits

Generate SSH Key with Linux (Ubuntu)

Public key type: ecdsa-sha2-nistp256 keys of 256 bits

Ubuntu’sssh implementation of the rsa  algorithm is not be fully supported by Pressable, however the ed25519 algorithm should work just fine. A Public key can be generated for Linux debian distribution with the following steps below:

  • Open Terminal
  • Run this command: ssh-keygen -t ed25519

When you execute the command, the ssh-keygen utility prompts you to enter the name of the file you want the key to be stored in. The name of the key can be entered without any extension like for ex. id_ed25519. Leaving the  name blank will generate a default name and put the file within your ~/.ssh directory

Type in a passphrase when prompted. You can hit the ENTER key to accept the default (empty for no passphrase). However, it is recommended to always use a passphrase when generating your public key for security reasons.

Enter the passphrase for the second time to continue, the terminal will generate the key pair automatically.

To see the generated key files you can run ls command to see a list of files inside the corresponding directory. In this case, the key was stored within the .ssh directory.

For security reasons, only the following key types and lengths are allowed

  • ssh-rsa keys from 2048 to 16384 bits
  • ecdsa-sha2-nistp256 keys of 256 bits
  • ssh-ed25519 keys of 256 bits