Skip to content

Generate an SSH key

Generate an SSH key pair on Linux, macOS, or Windows for use with the Stack Harbor PaaS SSH Gate. Covers ECDSA, EdDSA, and RSA key types.

Generating an SSH key pair is the first step before you can add a public key to your PaaS account and connect to environments through the SSH Gate. The platform supports the three modern key types:

  • EdDSA (Ed25519) — small, fast, recommended default.
  • ECDSA — elliptic-curve, good performance.
  • RSA — long-established, widely compatible. Use at least 2048 bits; 4096 is preferred.

If you already have a key pair you use for other services, you can reuse it — there is no requirement to generate a new one for the PaaS.

Linux and macOS

Both ship ssh-keygen in the base install. On macOS, it lives at /usr/bin/ssh-keygen and is available in any terminal.

ssh-keygen -t ed25519 -C "your_email@example.com"

When prompted:

  • Enter file in which to save the key — accept the default (~/.ssh/id_ed25519) unless you have a reason to use a different filename.
  • Enter passphrase — strongly recommended for any key you use in production. The passphrase encrypts the private key on disk; ssh-agent keeps it unlocked once you’ve entered it the first time per session.

Two files appear in ~/.ssh/:

  • id_ed25519 — the private key. Never share it, never commit it.
  • id_ed25519.pub — the public key. This is what you paste into the dashboard.

Generate an RSA key (compatibility)

If you need RSA for a tool that does not speak Ed25519 yet:

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

View a public key

cat ~/.ssh/id_ed25519.pub

Copy the entire single-line output — it starts with ssh-ed25519 (or ssh-rsa, ecdsa-sha2-nistp256, etc.) and ends with the comment. That is what you paste into the Add Public Key dialog in the dashboard.

Windows

Modern Windows 10 and 11 ship OpenSSH by default — ssh-keygen works the same way in PowerShell as on Linux/macOS:

ssh-keygen -t ed25519 -C "your_email@example.com"

If you prefer a GUI tool, use PuTTYgen (bundled with PuTTY).

PuTTYgen workflow

  1. Download and run PuTTYgen.
  2. Pick the key type at the bottom — EdDSA (Ed25519) or RSA. For RSA, set the bit size to at least 2048; 4096 is preferred.
  3. Click Generate and move the mouse over the blank area until the progress bar fills.
  4. (Optional) enter a Key passphrase to encrypt the private key on disk.
  5. Click Save private key and store the resulting .ppk somewhere safe.
  6. To get the public key in OpenSSH format, copy the multi-line block from the top of the PuTTYgen window labelled “Public key for pasting into OpenSSH authorized_keys file”.

Convert the private key to OpenSSH format

If you also need the private key in OpenSSH format (for tools that don’t speak .ppk), use Conversions → Export OpenSSH key and save the resulting file. Open it in any text editor to copy its body.

Next step

Add the public key to your PaaS account — see Add an SSH key. After that, you can connect to any of your environments through the SSH Gate using the private key from this pair.

See also