SSH Public Key Setup

How to configure and setup SSH public keys, the right way.

Step #1

$ ssh-keygen -t rsa -b 4096Generating public/private rsa key pair.Enter file in which to save the key (/home/bob/.ssh/id_rsa):Enter passphrase (empty for no passphrase):Enter same passphrase again:Your identification has been saved in /home/bob/.ssh/id_rsaYour public key has been saved in /home/bob/.ssh/id_rsa.pubThe key fingerprint is:SHA256:ShpCF11/fYjujAVDYivNKpNM6QdVwh8Z9sX00PIspdobob@localhostThe key’s randomart image is:+ — -[RSA 4096] — — +| .oooBo.o+. || +o*o* .o=o. || . = ..+.= o*+ .|| . = o o. =o o. || . B + S oo. || . B . .=E || . . . o || || |+ — — [SHA256] — — -+

Step 2:

$ ssh-copy-id bob@server-name
$ cat /home/bob/.ssh/authorized_keys
# Bob’s key
ssh-rsa AAAAB3NzaC1yc2EAAAADAQAB… bob

Step 3

ssh -i /home/bob/.ssh/id_rsa bob@server-name
The authenticity of host ‘server-name (10.1.1.1)’ can’t be established.ED25519 key fingerprint is SHA256:LKVs+g5kgmIXsYkU2Fl8XmNOmW4Rz1/AoXBLdRoanzM.This key is not known by any other namesAre you sure you want to continue connecting (yes/no/[fingerprint])?

Step 4:

$ nano /etc/ssh/sshd_configPasswordAuthentication: no
$ sudo systemctl restart sshd
$ sudo systemctl status sshd

Problems at scale:

This article was originally published at: https://www.bastionxp.com

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ganesh Velrajan

Ganesh Velrajan

Ganesh Velrajan is the founder of Ampas Labs Inc. Learn more about our SSH Remote Access Solutions at https://www.socketxp.com and https://www.bastionxp.com