SSH CheatSheet

This is a list of useful commands and settings when dealing with SSH connections.

File & Folder permissions

These are the required permissions to make files like your private keys work as the system would deny to use them if the permissions are too open.

.ssh  = 700 (drwx------)
.pub  = 644 (-rw-r--r--)
.pk   = 600 (-rw-------)

.ssh = this directory is usually located in your home directory (e.g. ~/.ssh).
.pub = is the public key file to use for authentication (e.g. id_ed25519.pub)
.pk = is the private key file to use for authentication (e.g. id_ed25519)

Kill other sessions

This command kills the oldest ssh session for the specified user.

Note: If only one session exits and you're connected via SSH your own connection will get terminated.

pkill -o -u <username> sshd