rescueshell Start trial

Revoke a leaver's SSH access on remote devices

A person who could log in to your devices has left, or a laptop with their key is lost. Closing that door is easy on one server and slow on a fleet of devices in other people's buildings, some of them offline. Here is what has to change, where the usual setups make it hard, and how to do it with a relay.

What there is to revoke

Three things can let a person in, and removing one does not remove the others:

So the job is two parts: cut the paths, then take the key off each device. Cutting the path is quick. Taking the key off is the part that gets put off.

Where it gets hard

Options, and what each asks of you

Edit authorized_keys by hand or with a config tool

The plain answer, and fine when you have a few devices you can reach. List the keys, remove the line, and keep the rest, and keep your own session open until the new list is tested. With a tool such as Ansible you can push the same list to many devices at once, which works when every device is reachable from where you run it. Devices behind NAT are not, so you also run a path to them: see jump hosts and NAT.

Cut the path: the jump host or the VPN

If people reach devices only through a jump host or a VPN you run, deleting their login there stops new connections. It does not touch the keys on the devices, and a shared key the devices use to dial in to that host is still known to them. Treat that key as exposed and replace it on each device.

A hosted relay with per-device key lists

With a relay the two parts are separate and you can do them in order. First, remove the person from the team, which stops their shells at once. Then take their key off the devices, as a signed change. The rest of this page is that route, and its limits.

RescueShell steps

This is the order we would use. We have not run these exact commands for this page, and a team's own setup differs: check them on a test device first. The agent on each device connects out to our relay. The device's own OpenSSH server checks a key from the device's own list of trusted keys, and our servers cannot add a key to that list or take one off it.

1. Remove the person from the team

An admin does this under Team, then Members. Removing someone, or demoting them to viewer, ends their open shells right away and stops them opening new ones through RescueShell, on every device, online or not. The relay reads a person's role on each request. See roles.

That is access through us. It does not edit any device, so the key is still on each device's list. If the person can reach a device another way, for example your own VPN or its SSH port on a LAN, the key still works there. Cut those paths too.

2. Find the key on each device

Open the device under Devices and its Checklist. It lists the trusted keys the device last reported, by fingerprint. That is what the device told us, and it can be a little out of date: the device is the authority. Match the fingerprint to the leaver's public key with ssh-keygen -l -f their_key.pub.

3. Remove the key with a signed change

The device only takes a change that is signed by a key it already trusts, so sign with your own key, not the leaver's. From the CLI:

rescueshell trust pump-07 --sign-with ~/.ssh/id_ed25519 --remove-key ./leaver.pub

Change pump-07 to the device name, --sign-with to your own private key and --remove-key to the leaver's public key, as a file or the key line. The command shows the key fingerprint and the key that signs, and asks before it sends anything. The device checks the signature itself, then applies the change. The device refuses a list with no key left or no login account, so you cannot remove the last one this way.

For devices installed as a group, the same change can be signed in one run for every online device in the group: rescueshell trust --group NAME --sign-with KEY --remove-key FILE. Add --check instead of --sign-with to list the devices that still differ. The CLI refuses a batch that would remove the key that signs it. If a device keeps the old list, see the limits below.

4. If nothing left on the device can sign

Run the install command again on the device as root. It asks for a registration pass, replaces the device's list with the one in the command, and prints will remove: for each key or account that would go, before it asks [y/N].

curl -fsSL https://releases.rescueshell.com/latest/install.sh | sh -s -- \
  --base-url https://releases.rescueshell.com/latest --relay https://app.rescueshell.com \
  --name pump-07 --trust-keys-from pi

Change pi to the account whose keys you log in with, and pump-07 to the device's name. Be careful with the last flag: --trust-keys-from re-trusts every key in that account's authorized_keys, including the leaver's. Remove the leaver's line from that file first, or replace the last flag with --trust-key 'ssh-ed25519 AAAA… you@laptop' --allow-user ACCOUNT. See add a device for the other options.

What it does not do

How to choose

If the shell does not open, see the shell does not open.

Try it on one device

The first device is free to try with no card, for 30 days from when it connects, not from when you sign up. Start a trial.