SSH

To close an SSH connection, press the Return key, then type ~.

Using SSH keys

Generate a key:

# On newer systems
ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -C 'name@example.com'

# On older systems
ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_rsa -C 'name@example.com'
-t
The type of key, which defaults to RSA.
-b
The number of bits. This is ignored for the newer Ed25519 scheme.
-f
The filename of the new private key. The public key will have the same filename with .pub appended.
-C
An optional free text comment. On MacOS, it defaults to username@hostname.local.

Add the new key to ssh-agent:

# Start the agent in the background
eval "$(ssh-agent -s)"

# Add the key
ssh-add ~/.ssh/id_ed25519

You can assign keys to specific hosts in ~/.ssh/config:

Host codeberg.org
    User git
    IdentityFile ~/.ssh/codeberg_ed25519

Host github.com
    User git
    IdentityFile ~/.ssh/github_ed25519