The Best Ways to Share SSH Keys Safely at Work

The Best Ways to Share SSH Keys Safely at Work

An SSH key exchange can become a long-lived access problem in seconds. A private key pasted into chat, attached to a ticket, or committed to a repository may grant durable access to production systems long after the original task is complete. The best ways to share SSH keys start by separating public-key distribution from private-key custody, then applying controls that match the access risk.

For most engineering teams, the correct answer is not to send an SSH private key at all. Give each person, service, or automated workload its own identity, distribute only the public key where needed, and make access revocable. When a private key truly must change hands, treat it as a secret with a short exposure window, strict recipient controls, and an immediate rotation plan.

Start With the Rule: Public Keys Can Be Distributed, Private Keys Should Not

An SSH public key is designed to be installed on a destination host, usually in an account’s `authorized_keys` file or through an identity provider, cloud console, or configuration-management system. It identifies a key holder but does not enable someone to impersonate that holder. Sharing a public key through a ticket, internal documentation, or a reviewed infrastructure change is generally acceptable, provided the recipient and destination are correct.

The private key is different. It proves possession of that identity. Anyone who receives an unprotected private key can authenticate as its owner until the key is revoked, removed, or its access is otherwise constrained. Email, Slack, Teams, shared drives, issue trackers, source control, and personal password managers are poor transfer channels when they lack purpose-built secret controls.

This distinction should drive policy: collect public keys broadly when onboarding access, but prohibit routine transfer of private keys. If a team frequently needs to pass private keys among people, the underlying access model needs attention.

Best Ways to Share SSH Keys for Different Access Models

1. Let each human user generate and retain their own key pair

For administrator and developer access, the preferred model is simple: each person creates their own key pair on a managed device, protects the private key with a strong passphrase, and submits only the public key. The platform team installs that public key through approved infrastructure workflows.

This preserves accountability. Audit logs, authorized-key comments, and identity records can tie access to an individual rather than a generic shared credential. It also limits the blast radius of device loss or employee departure. Removing one public key removes one person’s access without interrupting everyone else.

Use modern key types such as Ed25519 where compatibility permits. RSA keys may still be necessary for legacy systems, but they should be at least 3072 bits. Disable weak algorithms and avoid unencrypted private key files.

2. Distribute public keys through infrastructure as code

For fleets of servers, manually editing `authorized_keys` does not scale and creates drift. Store approved public keys in a reviewed configuration repository or identity inventory, then deploy them with tools such as Terraform, Ansible, cloud-init, or your endpoint and configuration platform.

A public key in an internal repository is usually acceptable, but do not confuse public key management with secret management. Repository protections still matter: branch review, least-privilege write access, clear ownership, and a dependable offboarding process prevent unauthorized access from being added quietly.

Infrastructure as code also makes removal predictable. When a contractor leaves or an employee changes teams, remove their public key in the source of truth and deploy the change. Periodic reconciliation should confirm that hosts match the intended state.

3. Use SSH certificates for teams that need scale and short-lived access

SSH certificates are often a better solution than managing permanent keys across many systems. Users retain their own key pair, while a trusted certificate authority signs a short-lived certificate that grants access to specific principals, environments, or roles.

The practical benefit is expiration. A certificate issued for eight hours or one day naturally becomes unusable after the approved window. You do not need to update every server whenever a temporary access request ends. Certificate authorities also support stronger policy decisions, including identity verification, role-based access, and separate production controls.

This approach has operational overhead. You must protect the signing authority, define issuance policy, and integrate it into developer workflows. For a small team with a few static hosts, managed public keys may be enough. For production estates with frequent access changes, certificates substantially reduce standing privilege.

4. Use a secure secret-transfer workflow for rare private-key handoffs

There are legitimate exceptions. A recovery key may need to be transferred to a designated incident responder. A vendor may need a temporary credential for a narrowly defined migration. A service account key may have to move from a controlled build environment into a vault during a transition.

In these cases, use a dedicated secret-sharing mechanism rather than ordinary collaboration tools. The transfer should encrypt the secret, limit access to intended recipients, expire quickly, and provide visibility into whether it was opened. Burn-on-view controls are useful when a recipient only needs one opportunity to retrieve the material.

Securitae is suited to this pattern: create a restricted Secure Link for the one-time handoff, then rotate the transferred key after the task is complete. The platform’s collection workflow is also useful when a client or third party needs to submit a credential without creating an account.

The secure link is not a reason to make a sensitive key permanent. It is a controlled exception path. Record the owner, business purpose, recipient, expiry, and rotation action before sharing.

5. Put machine credentials in a secrets manager, not in people’s inboxes

Automation creates a different problem. CI runners, deployment agents, backup systems, and integration jobs cannot generate an interactive key pair every time they run. They may need a private key, but that key should be stored in an approved secrets manager or workload identity platform, not copied between engineers.

Access should be granted to the workload identity that needs it. The secret should be injected only at runtime, protected from build logs, and unavailable to unrelated pipelines. Restrict the corresponding server-side public key with source, command, or forwarding limitations where appropriate.

For example, an automation key that only deploys releases should not support interactive shell access, agent forwarding, port forwarding, or access from arbitrary networks. SSH `authorized_keys` options and forced commands can reduce what a stolen automation credential can do.

Controls That Make SSH Key Sharing Defensible

A sound transfer method can still fail if the key itself has excessive reach. Before distributing any key, identify the account it authenticates, the systems it reaches, who owns it, and how it will be revoked. Shared `root` keys and generic administrator accounts are especially difficult to audit and should be eliminated where possible.

Passphrases remain valuable for human-held private keys, but they are not enough on their own. Managed endpoints, hardware-backed storage, disk encryption, and MFA at the access-broker or certificate-issuance layer add meaningful protection. Avoid enabling SSH agent forwarding by default, because it can expose a usable authentication path on intermediary hosts.

Rotation should be event-driven as well as scheduled. Rotate immediately after accidental exposure, a misdirected delivery, a contractor offboarding, suspicious authentication activity, or a major change in key ownership. Routine rotation intervals can help for high-value service credentials, but short-lived certificates and just-in-time access are usually more effective than rotating static keys on an arbitrary calendar.

Logging completes the control set. Centralize SSH authentication logs, alert on unexpected source networks and failed attempts, and retain enough context to answer who accessed production, from where, and under which identity. A key without ownership and observability is not a manageable credential.

Common Shortcuts That Create Long-Term Exposure

Teams often use the fastest available channel during an incident or onboarding rush. The following patterns deserve explicit prohibition because they spread secrets into systems built for retention, search, forwarding, and broad access:

  • Sending private keys through email, chat, or ticket comments.
  • Committing private keys, even encrypted ones, to source repositories.
  • Reusing one private key across people, environments, or vendors.
  • Keeping vendor access active after a project closes.
  • Sharing an SSH agent socket or forwarding agents through untrusted hosts.

The operational cost is easy to underestimate. Once a private key lands in a chat archive or repository history, deleting the message does not prove the key is gone. Assume compromise, remove the associated public key, issue a replacement, and investigate access logs.

Build the Process Around Revocation, Not Convenience

The strongest SSH access programs make removal routine. Every key should have an owner, a scope, an approval path, and a known revocation method. Public keys should flow through controlled deployment. Temporary access should expire automatically. Private key transfer should be exceptional, time-bound, and followed by rotation.

When an urgent request arrives, ask a more useful question than “What is the fastest way to send this key?” Ask whether the recipient needs the private key at all, how long the access must last, and how you will prove it is gone afterward. That question prevents a short-term handoff from becoming a permanent production risk.


Leave a Reply

Your email address will not be published. Required fields are marked *