Cloud concept · Updated

SSH Public-Key Authentication - SSH public-key authentication lets a client log in to an SSH server by proving it holds the private key for a public key the server accepts.

In short

The SSH client signs data tied to the connection, and the server verifies the signature without receiving the private key. This lets engineers grant and revoke access for individual people or workloads without distributing a shared login password.

Cloud Concepts Hub →

6 key aspects of SSH Public-Key Authentication

SSH public-key authentication combines proof of private-key possession with server-side account authorization, while key lifecycle and host verification remain separate operational responsibilities.

01
Proof of private-key possession

The client signs session-specific data and the server verifies the signature. Only the public key needs to be registered with the server or access service.

02
Key generation and custody

Generate a separate key pair for each person or workload and select a key type supported by the clients, servers, and security policy. Protect interactive private keys with a passphrase or use a hardware-backed key where supported.

03
Authorization for a specific account

The server decides which keys or certificate principals can authenticate to the requested OS account. Use a least-privileged account rather than granting administrative access to every accepted key.

04
Static keys and short-lived certificates

A static public key works until its authorization is removed. A trusted SSH CA can instead issue short-lived certificates for approved principals, reducing the need to update individual keys on every host.

05
Lifecycle and recovery

Test the replacement credential before removing the old one, and keep a recovery path for lockouts. When a static key is compromised, remove its authorization wherever it was installed; closing access to new logins does not terminate existing sessions.

06
Separate trust in the server

Verify the server's host key or host certificate independently of the user credential. Investigate an unexpected host-key change rather than bypassing the warning.

Cloud services for SSH Public-Key Authentication

VM services such as Amazon EC2, Compute Engine, and Azure Virtual Machines can provision a public key for a guest OS account. On EC2, EC2 Instance Connect adds an IAM-gated way to make a public key available briefly instead of relying on a permanent entry for each developer. Compute Engine's OS Login offers a different identity-managed approach, replacing metadata-based keys with access tied to IAM. A team can use a separate credential for AWS Transfer Family when it needs file transfer without shell access. Across these services, the SSH client still proves possession of the private key, while each service or guest OS controls where that credential is accepted.

Amazon EC2Amazon EC2

For Linux instances launched from images that support EC2 key-pair provisioning, the launch-time public key is installed for the image's default login user. Engineers can import a public key generated on a workstation and keep the matching private key local.

Virtual Machines

When provisioning a Linux VM, engineers can supply a public key for the administrator account. The matching private key remains with the SSH client and is not required by Azure to provision that account.

AWS Transfer FamilyAWS Transfer Family

A service-managed SFTP user can have SSH public keys registered for authentication. The same proof of private-key possession grants access to the configured file-transfer account rather than an interactive shell.

What is SSH Public-Key Authentication

2 min read

SSH public-key authentication proves that a client holds a private key authorized for a particular account. The client signs data tied to the current SSH session, and the server verifies the signature with the corresponding public key. The private key stays with the client or with a signer acting on its behalf, such as a hardware token. Simply knowing or copying a public key does not let someone log in, but being able to add a public key to an account's authorized keys can grant access to that account.

For a development VM, generate a dedicated key pair on a trusted workstation with an OpenSSH command such as ssh-keygen -t ed25519 -f ~/.ssh/dev_vm if both ends and local policy support Ed25519. Choose a passphrase for an interactive user's private key. Register only dev_vm.pub for the intended OS account, for example through instance provisioning or the account's ~/.ssh/authorized_keys file. After verifying the server's host key against a trusted source, test the login with ssh -i ~/.ssh/dev_vm devuser@dev.example.com. Keep an existing session or recovery path available when changing authentication settings so a configuration mistake does not lock out administrators.

In the cloud, a provisioning system may install a key at instance creation, or an identity-aware access service may make a key available to the server for a short time. Neither approach makes the SSH endpoint reachable or grants OS permissions by itself: the connection still needs an allowed network path, and the authenticated account still needs the right permissions. If login fails, check the target username, which key the client is offering, and the server's key source, file permissions, and authentication logs. A key shown in a cloud console is not necessarily the key the guest OS currently accepts.

For a larger fleet, an SSH certificate authority can sign a developer's public key to issue a short-lived OpenSSH user certificate. Configure servers to trust the CA and accept only the appropriate certificate principals for each account. The client still proves possession of the matching private key; the certificate tells the server which identities the CA approved and for how long. An SSH user certificate is not a TLS certificate. Certificates reduce per-host key distribution, but they require a protected CA signing key and a reliable issuance process.

Static keys are easy to deploy on a few hosts, but rotation and offboarding require removing trust everywhere the old key was authorized. Deleting the local private-key file does not revoke copies. Use separate credentials for people and automation, keep private keys out of repositories and VM images, and remove authorization promptly if a key is exposed. A passphrase protects a stored private-key file; by itself it is not a second factor verified by the server. Client authentication is also separate from host verification and transport encryption: the host key identifies the server, and SSH uses session keys to encrypt traffic.

SSH Public-Key Authentication exam questions

Real practice exam questions on SSH Public-Key Authentication, with the correct answer and its explanation. Answer them with every option in the exam simulator.

DVA-C03

A developer needs occasional SSH access to a running Amazon Linux 2023 development instance. The instance already supports EC2 Instance Connect, and the developer's workstation can reach its SSH port. The security team requires each new login to use a freshly generated key pair, with the private key kept on the workstation. AWS IAM must authorize each public key submission, and the instance must stop accepting that key for new logins after a short window without a cleanup script. Which solution meets these requirements?

Show answerCORRECT ANSWER

Generate a key pair on the workstation for each login. Use the developer's IAM credentials to submit the public key with SendSSHPublicKey, then connect with the matching private key within 60 seconds.

EC2 Instance Connect checks IAM permissions for SendSSHPublicKey and makes the public key available to the instance for 60 seconds. The SSH client uses the private key locally. The window limits new authentication with that key; it does not end an established session.

Practice SSH Public-Key Authentication in a full exam

Questions on SSH Public-Key Authentication in each practice exam, with every answer option and an explanation for each:

Start a free practice exam