Skip to content
shellhacks.dev
SSH and Networking

Create an Ed25519 key

Create an Ed25519 key pair with ssh-keygen -t ed25519. Name the file with -f, label it with -C, and set a passphrase instead of the empty one used here.

1 min read
Summarize in AI

You need a new SSH key, and Ed25519 is the type to pick unless a server forces something else.

Shell
ssh-keygen -q -t ed25519 -f ./demo_key -C '[email protected]' -N ''
ls -l demo_key demo_key.pub | awk '{print $1, $5, $9}'
cut -d' ' -f1,3 demo_key.pub
Text
-rw------- 411 demo_key
-rw-r--r-- 99 demo_key.pub
ssh-ed25519 [email protected]

-t ed25519 picks the key type, -f names the private file and writes the public one beside it with .pub added, and -C sets the comment at the end of the public line. Ed25519 keys are short, fast to verify and have no size to choose, which is the argument made in the ssh-keygen manual. The permissions on the private file are set to 600 for you, as the first column shows.

-N '' means no passphrase and is used here only so the example runs without a prompt. Leave the option out on a real key and ssh-keygen asks for one, or the file on disk is all an attacker needs. Ed25519 needs OpenSSH 6.5 or later on both ends, and a few old appliances still accept only RSA.

Share

More snippets

SSH and Networking

Show a key's fingerprint

Show the fingerprint of a key with ssh-keygen -lf. The default hash is SHA256, and -E md5 prints the older format that some web consoles still list.

1 min read
SSH and Networking

Change a key's passphrase

Change or remove the passphrase of an existing key with ssh-keygen -p. Pass -P and -N only in a throwaway demo, since they put secrets in the process list.

1 min read
SSH and Networking

Extract a public key from a private key

Rebuild a public key from a private key file with ssh-keygen -y. The output holds the type and the key but no comment, so it differs from the .pub file.

1 min read

Get new posts by email

One email when a new post is published. No spam.

Unsubscribe in one click. No spam, ever.