# SSH host keys, ciphers and key exchange

Two things on the **SSH** tab of an [SFTP listener](Ports-SFTP.md) decide how safe the port is and which clients can use it: the host keys, by which the server proves who it is, and the algorithms it offers.

## Host keys

Every SSH server has a host key. A client remembers it at the first connection and warns loudly when it is another one later.

| Setting | Key file on a new server | New listener |
|---|---|---|
| **Server Host Key (RSA) enabled** | `./ssh_host_rsa_key` | on |
| **Server Host Key (ECDSA) enabled** | `./ssh_host_ecdsa_key` | on |
| **Server Host Key (ED25519) enabled** | `./ssh_host_ed25519_key` | on |
| **Server Host Key (DSA) enabled** | `./ssh_host_dsa_key` | off: "DSA is not secure. You should stop using DSA as soon as possible." |

The files are in the server's folder and are made by the server the first time the port starts. **Browse** points a key at another file.

A client uses the first kind of key that both sides know. Offering RSA, ECDSA and ED25519 together serves old and new clients.

### Keep the keys

The host key files are the server's identity for every partner who ever connected.

- **Back them up** with the server's settings.
- When you move the server to another machine, **take them along**. With new keys, every client of every partner shows a warning or refuses to connect, and scripts stop.
- In a cluster and behind a load balancer, all servers need the **same** key files.
- Keep them readable for the server's account only.

To change a key on purpose, tell the partners beforehand and give them the new fingerprint.

## The sets

**Ciphers, MACs and key exchanges this port offers** chooses the algorithms.

| Set | Holds | Who can connect |
|---|---|---|
| **Recommended** | "Everything Maverick Synergy rates strong: AES-GCM, AES-CTR, curve25519, ECDH, the large SHA-2 Diffie-Hellman groups and SHA-2 MACs." | "Clients from about 2014 on connect." |
| **Strict** | "Only what Maverick Synergy rates highest: AES-GCM and chacha20-poly1305, curve25519 and the 3072 bit and larger SHA-512 Diffie-Hellman groups, SHA-512 MACs." | not clients from before about 2016, and not older Java libraries |
| **Compatible with older clients** | Recommended, "and for clients that know nothing newer: the two SHA-1 key exchanges with a 2048 bit or larger group, and hmac-sha1" | nearly everything still in use |
| **CrushFTP 11 lists** | "The lists a CrushFTP 11 port was created with, weak ones included (3DES, RC4, MD5 and SHA-1 MACs, SHA-1 key exchanges), for a partner that cannot be moved yet." | everything a CrushFTP 11 port served |
| **Custom: the lists below as they are** | your own lists | as you choose |

A new listener is on **Recommended**.

"The port follows this set when a later version changes it": with one of the four named sets, an update of the server that improves a set improves your port. With **Custom**, the lists stay as you left them, for good and for bad.

## The lists

Below the set, the three lists show what it holds, in the order of preference:

| List | Recommended holds |
|---|---|
| **Supported Ciphers & Preferred Order** | `aes256-gcm@openssh.com`, `aes128-gcm@openssh.com`, `aes256-ctr`, `aes192-ctr`, `aes128-ctr`, `chacha20-poly1305@openssh.com` |
| **MAC List** | `hmac-sha2-256-etm@openssh.com`, `hmac-sha2-512-etm@openssh.com`, `hmac-sha2-256`, `hmac-sha2-512` |
| **Supported Key Exchanges** | `curve25519-sha256`, `curve25519-sha256@libssh.org`, `ecdh-sha2-nistp521`, `ecdh-sha2-nistp384`, `ecdh-sha2-nistp256`, the Diffie-Hellman groups 18, 17, 16 and 15 with SHA-512, group 14 with SHA-256, and the group exchange with SHA-256 |

Each entry can be removed with its **×**, and the order can be changed. "Changing a list by hand makes the three lists this port's own (Custom). A SHA-1 key exchange in a list of the port's own is only offered while the port's sha1_key_exchanges setting is true."

## One old partner

When a single partner has a client that cannot speak the Recommended set, do not weaken the port for everybody:

1. Add a second SFTP listener on another port.
2. Put it on **Compatible with older clients**, or the CrushFTP 11 lists if it must be.
3. Restrict it by address to that partner: [IP restrictions of a port](Ports-IP-Restrictions.md).
4. Ask the partner for a date by which they update.

## What an audit asks for

| The scanner says | Do |
|---|---|
| CBC ciphers, 3DES, arcfour offered | use Recommended or Strict: neither has them |
| SHA-1 in key exchange or MAC | Recommended or Strict |
| `ssh-rsa` with SHA-1 accepted | **RSA Sha1 Signatures Supported** off, as on a new listener |
| DSA host key | **Server Host Key (DSA) enabled** off |
| weak Diffie-Hellman group | **Minimum DH Key Size** 2048 or more |

In [FIPS mode](FIPS-Mode.md), the port offers only what is approved there, whatever the lists say.

The same algorithms count when the server itself connects out as a client: see [Ciphers](Prefs-Encryption-Ciphers.md).
