SSH key
A key pair used to log in over SSH: the private key stays on your machine and the public key is added to the server account.
Whoever holds the private key can log in to every host that trusts it.
In more detail
The public half is placed on the server in the account's authorized_keys file, and the private half stays with you and proves who you are. The private key must never be committed or shared, and can itself be protected with a passphrase.
Examples
ansible_ssh_private_key_file=keys/deploy_ed25519 tells Ansible which private key to use for a host or group.ssh-keygen -t ed25519 creates one. The client proves it holds the private key without sending it, and the server admits the user only if the public key is listed in that account's authorized_keys. Protect the private key with a passphrase.alias=prod host=server user=ana p=22 key=id_ed names the identity file a host alias uses.A copied private key logs in anywhere its public key is trusted, with no password.Related terms
- SSH — A protocol for logging in to and running commands on another computer securely over a network.
- Ed25519 — A modern public-key signature algorithm with small, fast keys, the recommended type for new SSH keys.
- connection variables — Inventory variables with reserved names, such as ansible_user, ansible_port and ansible_connection, that tell Ansible how to reach and log in to a host.
- secret — Any value that grants access, such as a password, access token or private key, and must be kept out of code and version control.
- private key — The secret half of a key pair, which proves its holder's identity and must never be shared.
- public key — The shareable half of a key pair, used by others to verify your signatures or encrypt data only you can read.
- authorized_keys — The file in a user's ~/.ssh directory listing the public keys allowed to log in to that account over SSH.
- ssh-agent — A background program that holds your decrypted private keys for a session so you do not retype passphrases for every connection.
- ssh-keygen — The OpenSSH tool for creating SSH keys and showing their fingerprints.
- key fingerprint — A short hash of a public key, such as SHA256:abc..., that people can compare to confirm two keys are the same.
- public key authentication — Logging in by proving you hold a private key whose matching public key the server already trusts, instead of typing a password.
Taught in
- Connections And Privilege Escalation — Ansible Configuration Management at Scale
- SSH Keys, The Agent And The Config File — Linux Fundamentals & Systems Administration
- Repositories You Configure By File — Red Hat Certified System Administrator (EX200) Exam Prep
- Containment & Eradication: Host, Net & Identity — Security Operations & Threat Hunting (SOC)
- Exam Strategy: The First Fifteen Minutes And ansible-doc — RHCE in Ansible (EX294): Automate Red Hat Systems
- ansible.cfg: Which File Wins, And The Settings That Matter — RHCE in Ansible (EX294): Automate Red Hat Systems
- SSH Keys And An Account For Ansible — RHCE in Ansible (EX294): Automate Red Hat Systems
- Privilege Escalation: sudo Rules And become — RHCE in Ansible (EX294): Automate Red Hat Systems
- Mock Exam, Part 2: Real Machines And The Patterns That Fail — RHCE in Ansible (EX294): Automate Red Hat Systems
References
- ssh-keygen(1) manual page
- Connection methods and details
- RFC 4252: The Secure Shell (SSH) Authentication Protocol
- OpenBSD manual: ssh-keygen
- OpenBSD manual: sshd authorized_keys format