"Can you send me the SSH key for the server?" It's one of the most common requests in any small engineering team, and it's usually answered by pasting a private key into Slack. That key then grants access to the server to anyone who can read that conversation, for as long as the key is valid, which is usually forever.
Here's how to do it properly.
Public keys vs private keys
An SSH key pair has two halves:
- The public key (
id_ed25519.pub) is safe to share with anyone. You put it on servers to say "let the holder of the matching private key in". - The private key (
id_ed25519) is the secret. Anyone who has it can log in as you.
You almost never need to share a private key. You need to share access.
The right way: everyone gets their own key
Ask the person to generate their own key pair:
ssh-keygen -t ed25519 -C "alex@example.com"They send you their public key (~/.ssh/id_ed25519.pub). That's safe to send over Slack or email. You add it to the server:
# on the server, as the user they'll log in as
echo "ssh-ed25519 AAAA... alex@example.com" >> ~/.ssh/authorized_keysOr from your machine, if you already have access and their public key file:
ssh-copy-id -f -i alex.pub user@serverBenefits:
- Revocation is easy. When Alex leaves, delete their line from
authorized_keys. Nobody else is affected. - Logs show who logged in. Shared keys make every login look the same.
- No secret ever travels. The private key never leaves Alex's laptop.
For larger teams, look at SSH certificates or your cloud provider's access tooling (for example AWS Systems Manager Session Manager, Google Cloud OS Login, or Tailscale SSH), which avoid managing authorized_keys by hand.
When you really do have to share a private key
Sometimes there's no way around it: a deploy key baked into a legacy system, a vendor appliance with a single key, a break-glass key, or migrating a key to a new CI system. In that case:
1. Use a one-time encrypted link, not chat
Send the key file through a link that works once. With the Dropzone CLI, it's encrypted on your machine before upload:
curl -fsSO https://dropzone.sh/dropzone.mjs
node dropzone.mjs send ~/.ssh/deploy_keyThe recipient writes it straight to disk:
node dropzone.mjs open "$LINK" -o ~/.ssh/deploy_key
chmod 600 ~/.ssh/deploy_keyOr upload the file at dropzone.sh in the browser. Either way, what's left in the chat history is a link that no longer works.
2. Protect the key with a passphrase
A passphrase encrypts the private key on disk. If you're sharing it anyway, send the passphrase through a different channel than the key.
ssh-keygen -p -f ~/.ssh/deploy_key3. Limit what the key can do
In authorized_keys, you can restrict a key to specific commands or source addresses:
from="203.0.113.0/24",command="/usr/local/bin/deploy",no-port-forwarding,no-pty ssh-ed25519 AAAA...
4. Plan the rotation
A key that's been shared should be replaced when it's no longer needed, or as soon as anyone who had it leaves.
Never do this
- Commit a private key to a repository, even a private one.
- Paste a private key into Slack, Teams, email, a ticket or an AI chat.
- Reuse your personal key as a shared team key.
- Leave a shared key with no passphrase and full shell access.
Related: How to share API keys securely · How to share .env files with your team