Generate, install and manage SSH key pairs to replace passwords for safer remote access. 16.11.2025 | reading time: 2 min On Linux, SSH key pairs replace passwords for remote logins; this short guide shows how to generate a secure key pair with `ssh-keygen`, install the public key on a server and manage passphrases and the agent for convenient, safe access. Hands-on Example Try this example to create an ed25519 key pair and copy the public key to a server: ```bash ssh-keygen -t ed25519 -C "lab@example.com" Generating public/private ed25519 key pair. Enter file in which to save the key (/home/user/.ssh/id_ed25519): /home/user/.ssh/id_ed25519_lab Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/user/.ssh/id_ed25519_lab Your public key has been saved in /home/user/.ssh/id_ed25519_lab.pub ssh-copy-id -i /home/user/.ssh/id_ed25519_lab.pub user@remote-host Now connect: ssh -i /home/user/.ssh/id_ed25519_lab user@remote-host ``` Key Options & Uses Choose ed25519 for compact, modern keys or RSA 3072/4096 if compatibility is required, protect the private key with a passphrase, store keys in ~/.ssh with strict permissions (600 for private, 644 for public, 700 for ~/.ssh), place public keys in the server's ~/.ssh/authorized_keys, and use keys for SSH logins, Git access or automated scripts while balancing convenience and security. Practical Management Tips Load private keys into `ssh-agent` to avoid repeated passphrase prompts, use `ssh-add` to manage identities, deploy keys quickly with `ssh-copy-id`, verify remote host keys with `ssh-keyscan` and always rotate keys if a machine is compromised or when granting temporary access to contractors. Final Step Now that keys are created and tested, practice deploying them across hosts and automating agent workflows; deepen Linux skills and consider certification preparation such as CompTIA Linux+ or LPIC-1 with an intensive exam course at bitsandbytes.academy. Join Bits & Bytes Academy First class LINUX exam preparation. setup security network utilities