Generation
bash
ssh-keygen -t ed25519 -C "me@laptop" # recommended type
ssh-keygen -t rsa -b 4096 -C "legacy" # if RSA is required (old systems)
ssh-keygen -t ed25519 -f ~/.ssh/deploy_key # a custom filename (several keys)
ssh-keygen -p -f ~/.ssh/id_ed25519 # change/add a passphrase on the key
ssh-keygen -y -f ~/.ssh/id_ed25519 # recover the .pub from the private key
ssh-keygen -l -f ~/.ssh/id_ed25519.pub # fingerprint
ssh-keygen -t ed25519 -N '' -f key # no passphrase (for automation/CI)
Installing on the server:
bash
ssh-copy-id user@host # the simplest way
ssh-copy-id -i ~/.ssh/deploy_key.pub user@host # with a specific key
cat ~/.ssh/id_ed25519.pub | ssh host 'cat >> ~/.ssh/authorized_keys' # manually