Create an SSH key with ssh-keygen and log in without passwords
A password over SSH can be guessed or leaked; a key is never sent over the network at all. ssh-keygen generates a key pair: a private key that stays with you and a public key that goes on the server. This guide follows the official ssh-keygen(1) manual page.
Generate the key
ssh-keygen -t ed25519 -C "sam@aiusdt"
-t picks the key type; ed25519 is the modern recommended choice. The -C comment is just a label to identify the key later. You will be asked for a save location (the default is fine) and a passphrase that protects the private key on your machine.
What you get
~/.ssh/id_ed25519the private key: never leaves your machine, never sent to anyone.~/.ssh/id_ed25519.pubthe public key: this is what goes on servers.
Install the public key on the server
ssh-copy-id user@server
Or manually: paste the .pub file's contents into ~/.ssh/authorized_keys on the server.
Test, then harden
- Log in with the key:
ssh user@server; the account password should no longer be asked. - Once key login works, disable password authentication in the server config to close the guessing door for good.
Common mistakes
- Sending the private key to anyone, even "support". The private key is never shared.
- No passphrase on a laptop key; whoever takes the device takes the servers.
- Loose file permissions; SSH refuses keys if your .ssh directory is writable by others.
After logging in: schedule tasks with cron to automate maintenance. Arabic version: ssh-keygen by Arabic.
