SSH Configuration

Posted on Jan 28, 2022

SSH Daemon (sshd) Configuration File

The SSH daemon settings can be entirely configured through its configuration file located at /etc/ssh/sshd_config. Use a text editor to modify it.

Recommended settings:

PermitRootLogin no
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
PasswordAuthentication no

How To Use SSH Keys

The client creates a private key and sends a public key to the server.

Private <-> Client

Public <-> Server

  1. Create key pair in client
$ ssh-keygen -b 4096
  1. Copy public key to server
$ ssh-copy-id -i ~/.ssh/mykey.pub user@127.0.2.1
  1. Start SSH authentication agent
$ eval $(ssh-agent -s)
  1. Add private key to ssh-agent
$ ssh-add ~/.ssh/id_rsa