Sitemap

SSH Server Pubkey Auth

Jun 17, 2025

--

Setup ssh server that authenticates using pubkey and disable password authentication.

sudo apt install openssh-server -y

Then edit the config file

sudo vim /etc/ssh/sshd_config

Set to the following below

PasswordAuthentication no
PermitRootLogin no
UsePAM no
KbdInteractiveAuthentication no

Get Kevin FOO’s stories in your inbox

Join Medium for free to get updates from this writer.

PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys

In your client, assuming your pubkey is at its default location. Cat the pubkey copy it.

cat .ssh/id_ed25519.pub

Paste the copied pubkey to the server authorized_key

vim .ssh/authorized_key

Restart ssh server

sudo systemctl restart sshd

< Back to all the stories I had written

--

--

Kevin FOO
Kevin FOO

Written by Kevin FOO

A software engineer, a rock climbing, inline skating enthusiast, a husband, a father.