Blog › Linux · Published 2026-11-26

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

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

  1. Log in with the key: ssh user@server; the account password should no longer be asked.
  2. Once key login works, disable password authentication in the server config to close the guessing door for good.

Common mistakes

After logging in: schedule tasks with cron to automate maintenance. Arabic version: ssh-keygen by Arabic.

Official sources

Need help with your project?
We build websites, systems and automation. Start your project WhatsApp

All articles