💾 Archived View for yaky.dev › notes › ssh-key-auth captured on 2024-12-17 at 10:05:31. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2024-09-29)

🚧 View Differences

-=-=-=-=-=-=-

SSH Key Authentication

SSH key authentication allows you to securely connect from your main Linux machine to a remote Linux machine without typing a password.

Generate SSH key pair

You only need to do this once (unless you reinstall the OS or delete the keys intentionally).

On your main machine:

ssh-keygen

Choose default location.

Do not set a passphrase.

This creates a key pair in ~/.ssh/

Copy SSH key to the remote machine:

Easy way, on your main machine:

ssh-copy-id username@remote.host

Enter the password for username on the remote machine.

Alternative way: (if SSH does not work, for example)

Copy the content of ~/.ssh/id_rsa.pub from your main machine:

cat ~/.ssh/id_rsa.pub

On the remote machine, create the SSH authorized keys file (if it does not exist)

mkdir ~/.ssh/
chmod 700 ~/.ssh  # this is important.
touch ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys  #this is important.

Copy the content of ~/.ssh/id_rsa.pub from your main machine to ~/.ssh/authorized_keys on the remote machine.

The key is now copied to the remote machine.

Log into the remote machine

ssh username@remote.host

Original source on DigitalOcean

Manually copying SSH keys on Red Hat Developer blog

home

email me: hi@yaky.dev

CC BY-NC yaky.dev