Generate SSH key

Ed25519 uses elliptic curve cryptography with good security and performance.

Create new key

ssh-keygen -t ed25519 -C "$(whoami)@$(hostname)" -P "" -f ~/.ssh/id_ed25519

or if you prefer email address

ssh-keygen -t ed25519 -C "" -P "" -f ~/.ssh/id_ed25519

Start the SSH agent in the background:

eval "$(ssh-agent -s)"

Update your ~/.ssh/config:

Host *
 AddKeysToAgent yes
 UseKeychain yes
 IdentityFile ~/.ssh/id_ed25519
 IdentityFile ~/.ssh/id_rsa

Add the private key to the SSH agent on macOS:

ssh-add --apple-use-keychain ~/.ssh/id_ed25519

Copy public key to clipboard

cat ~/.ssh/ | pbcopy

Once you have created a new SSH public key, this key can be copied to the .ssh/authorized_keys file on remote hosts to allow remote login or upload your key to GitHub

ssh-copy-id -i ~/.ssh/ root@remote.server.address

Generating a new SSH key and adding it to the ssh-agent