Back to blog
Security9 min read|

November 15, 2026

How to Rotate SSH Keys for SFTP Partners Without Downtime

A step-by-step process to rotate SSH keys for SFTP partners: overlap old and new keys, verify the cutover in logs, then revoke the old key safely.

How to Rotate SSH Keys for SFTP Partners Without Downtime

The engineer who set up your largest partner's SFTP integration left their company last month. Their key is still in your server's authorized_keys file, it was generated in 2019, and it lives in a cron job on a machine nobody on the partner side can name. You need to rotate SSH keys for SFTP access on that account, and the nightly order file cannot miss a single run.

Most key rotations that cause outages go wrong in the same way: the old key is removed and the new one added in a single step. This post walks through an overlap-based process that avoids that, covers when to skip the overlap entirely, and shows the commands to verify each stage.

Why SSH keys need rotating at all

An SSH key pair has no built-in expiry. Unlike a TLS certificate, a public key in authorized_keys keeps working until someone deletes it. That is convenient and also the core problem: access granted years ago is still valid today, whether or not anyone remembers granting it.

The realistic threats are mundane:

  • People leave - A private key on a former employee's laptop, home server, or backup drive is still a working credential.
  • Keys get copied - Private keys end up in CI variables, shared drives, configuration management repos, and ticket attachments. Every copy widens exposure.
  • Algorithms age - Old RSA keys under 2048 bits and the SHA-1 based ssh-rsa signature scheme are deprecated in current OpenSSH releases. A key that was fine in 2016 may fail to connect after a client upgrade.
  • Policy requires it - Many security policies and audit frameworks expect credentials to have a defined lifecycle, including periodic rotation and removal on role change. See the compliance requirements for MFT for how auditors tend to frame this.

Rotation is not a substitute for revocation. If a key is known to be compromised, you remove it immediately and accept the outage. The overlap process below is for planned rotations, where you control the timing.

If you need a refresher on how key pairs work in the first place, start with the SSH keys for SFTP beginner's guide.

The principle: overlap, then revoke

A safe rotation has three phases:

  1. Add the new public key alongside the old one.
  2. Verify that the partner's production job is authenticating with the new key.
  3. Revoke the old key after a short grace period.

During the overlap window, both keys work. That window is what removes the coordination problem. The partner can switch at a time that suits them, and you can confirm the switch from your side before anything breaks.

This only works if the server lets one account hold more than one authorized key. OpenSSH does by default, since authorized_keys is simply a list. If you are on a hosted SFTP platform, check that it supports multiple keys per user before you plan the window. If it does not, the fallback is a second temporary account, which is messier because the partner must also change the username.

How to rotate SSH keys for SFTP partners, step by step

The commands below assume an OpenSSH server and an account called acme whose keys live in /home/acme/.ssh/authorized_keys. Adapt the paths for chrooted or hosted setups.

1. Inventory the current keys

Start by listing what is actually authorized, with fingerprints:

ssh-keygen -lf /home/acme/.ssh/authorized_keys

The output shows the key size, the SHA-256 fingerprint, the comment, and the type for each line:

3072 SHA256:q2Xh9...kP0 jdoe@build01 (RSA)
256 SHA256:Mf7Lr...a1Q acme-prod-2024-03 (ED25519)

You are looking for two things: keys nobody can explain, and keys with weak types. A comment like jdoe@build01 tells you whose laptop or server generated it, which is often the best clue you have.

2. Have the partner generate the new key pair

The partner generates the key on the system that will use it. You never generate a private key on their behalf, and a private key should never travel by email or ticket.

Ask for Ed25519 and a descriptive comment that includes the date:

ssh-keygen -t ed25519 -C "acme-prod-2026-11" -f ~/.ssh/acme_sftp_2026

A comment convention such as <partner>-<environment>-<yyyy-mm> costs nothing and makes the next inventory trivial.

3. Receive and verify the public key out of band

The partner sends the .pub file through whatever channel you normally use. Before installing it, confirm the fingerprint over a second channel, such as a phone call or a message to a known contact:

ssh-keygen -lf acme_sftp_2026.pub

This step exists because the public key is the credential you are about to trust. If an attacker can swap the file in transit, the rest of the process is wasted.

4. Add the new key alongside the old one

Append, do not replace:

cat acme_sftp_2026.pub >> /home/acme/.ssh/authorized_keys
chmod 600 /home/acme/.ssh/authorized_keys

Agree on the end of the overlap window with the partner now, in writing. Two weeks is typical. Open-ended overlap windows are how old keys survive for years.

5. Partner tests the new key explicitly

The partner should test with the new key forced, so the client does not quietly fall back to the old one held in an agent or default path:

sftp -i ~/.ssh/acme_sftp_2026 -o IdentitiesOnly=yes acme@sftp.example.com

IdentitiesOnly=yes matters more than it looks. Without it, an SSH agent can offer the old key first, the login succeeds, and everyone wrongly concludes the new key works.

6. Confirm the cutover from the server logs

Once the partner updates their production job, verify it from your side rather than taking their word for it. OpenSSH logs the fingerprint of the key that authenticated each session:

grep "Accepted publickey for acme" /var/log/auth.log | tail -n 5
Accepted publickey for acme from 203.0.113.40 port 51122 ssh2: ED25519 SHA256:Zt4Wc...9eB

Compare the fingerprint against the one you verified in step 3. If the old fingerprint still appears after the partner says they switched, there is a second system using the old key that nobody mentioned. Finding that now, while both keys work, is the whole point of the overlap.

7. Revoke the old key and watch for failures

At the end of the window, remove the old line from authorized_keys. Then watch for failed authentications from the partner's addresses for the next few scheduled runs:

grep "acme" /var/log/auth.log | grep -E "Failed|Connection closed by authenticating user"

A failure right after revocation almost always means a forgotten job. Because you have the timestamp and source IP, the partner can usually find it quickly.

8. Record what happened

Write down the old and new fingerprints, the dates of each phase, and who confirmed the cutover. This is the evidence an auditor will ask for, and it is the starting inventory for the next rotation. Our post on audit logging for file transfers covers what a useful record looks like.

Rotating the server's host key

Rotation also runs in the other direction. Your server has its own host key, and every partner has pinned its fingerprint in their known_hosts file. Replace it without warning and every partner client fails with a "REMOTE HOST IDENTIFICATION HAS CHANGED" error, which a careful partner should treat as a possible attack.

The same overlap idea applies:

  • Announce first - Publish the new host key fingerprint to partners through a trusted channel before the change.
  • Serve both keys - OpenSSH can present several host keys. Clients from OpenSSH 6.8 onward that have UpdateHostKeys enabled learn the new key automatically while still trusting the old one.
  • Retire the old key later - Remove it only after partners confirm their known_hosts entries are updated.

Host key rotations are rarer than user key rotations, but they affect every partner at once, so they deserve more notice.

Setting a rotation policy

A policy turns rotation from a one-off project into routine maintenance. A workable baseline:

  • Scheduled rotation - Every 12 months for partner keys, or on the schedule your security policy sets.
  • Event-driven rotation - When a partner's technical contact changes, when a system holding the key is decommissioned, or when an algorithm is deprecated.
  • Emergency revocation - On suspected compromise, remove the key first and issue a new one after. Downtime is acceptable here.
  • One key per system - If a partner runs production and a disaster recovery site, give each its own key. You can then revoke one without touching the other.

With date-stamped comments in place, finding overdue keys is a short script:

#!/usr/bin/env bash
# Flag keys whose comment date (yyyy-mm) is more than 12 months old
cutoff=$(date -d "12 months ago" +%Y-%m)   # GNU date; on macOS use: date -v-12m +%Y-%m
for f in /home/*/.ssh/authorized_keys; do
  grep -oE '[a-z0-9-]+-[0-9]{4}-[0-9]{2}$' "$f" | while read -r comment; do
    stamp=${comment: -7}
    [[ "$stamp" < "$cutoff" ]] && echo "$f: $comment"
  done
done

Keys without a dated comment will not show up, which is itself a useful signal: those are the ones to inventory first.

Partner onboarding is the best time to set expectations about rotation. The SFTP partner onboarding guide covers how to put it in the intake checklist from day one.

Common pitfalls

  • Swapping instead of overlapping - Removing the old key in the same change that adds the new one turns a routine task into an incident.
  • Testing without IdentitiesOnly - An agent offers the old key, the test passes, and the real cutover fails on revocation day.
  • Trusting the partner's confirmation alone - Check the fingerprint in your logs. Partners often have more than one system using the same key.
  • No end date on the overlap - Without a fixed date, the old key never gets removed.
  • Sharing one key across systems - It makes every future revocation an all-or-nothing outage.
  • Generating keys for partners - Once you have held the private key, you cannot prove you no longer have it.

How FilePulse fits

FilePulse SFTP accepts public-key authentication only, with no password login, so keys are the one SFTP credential you have to manage. Admin and user accounts in the web app support MFA through TOTP, WebAuthn and passkeys, and accounts lock after repeated failed sign-ins. Activity is recorded in a tamper-evident, SHA-256 hash-chained audit log with signed checkpoints, which gives you a reliable record to support your rotation evidence. FilePulse is a fully managed service hosted in the EU, so there is no sshd configuration or host to patch on your side.

Next step: Start a 14-day free FilePulse trial, no credit card required, and set up your first key-only SFTP partner account.