Skip to main content

ssh: generate a key

Assume you will ssh from machine A to B.

On machine A

Go to .ssh:

cd ~/.ssh

Generate your key. Name it like id_TO_FROM_TYPE:

ssh-keygen -t ed25519 -f id_B_A_ed25519

Remember the passphrase in ssh agent (just for comfort):

ssh-add id_B_A_ed25519

Edit your configuration:

vim config

Edit your config and save:

Host NAME_YOU_WANT_USE
User USERNAME_ON_HOST
HostName IP_OR_HOST
IdentityFile PATH_TO_PRIVATE_KEY
IdentitiesOnly=yes

Copy the public key to clipboard:

cat id_B_A_ed25519.pub | pbcopy

On machine B

Edit authorized_keys:

vim ~/.ssh/authorized_keys

Append your public key from clipboard and save.