SSH Keys

Stolen from Digital Ocean:
https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-keys-on-ubuntu-1804

Create RSA key pair

Copy publickey to server

ssh-copy-id username@remote_host

cat ~/.ssh/id_rsa.pub | ssh username@remote_host “mkdir -p ~/.ssh && touch ~/.ssh/authorized_keys && chmod -R go= ~/.ssh && cat >> ~/.ssh/authorized_keys”

echo public_key_string >> ~/.ssh/authorized_keys

chmod -R go= ~/.ssh

chown -R sammy:sammy ~/.ssh

Make sure the authorized_keys content is on one line

Disable Password Authentication

sudo nano /etc/ssh/sshd_config

PasswordAuthentication no

sudo systemctl restart ssh

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.