home blog notes portfolio Ian Fisher

SSH

The ubiquitous network protocol for securely accessing remote servers.

Cheatsheet

Restart the SSH agent (macOS)

$ eval "$(ssh-agent -s)"

Restart the SSH daemon (Linux)

sudo systemctl restart sshd

Create a new key (macOS)

$ ssh-keygen -t ed25519 -C "ian@iafisher.com"
$ ssh-add --apple-use-keychain path/to/key
$ eval "$(ssh-agent -s)"

Add key to remote server

$ ssh-copy-id -i path/to/key USER@SERVER

Deny password authentication

In /etc/ssh/sshd_config:

PermitRootLogin no # or without-password
PasswordAuthentication no

Read logs

$ less /var/log/auth.log

Fix SELinux context

restorecon -R -v /home/$USER/.ssh

See also