Public Key Authentication

Connect securely to another machine without needing a password. Simplifies using SSH and performing automated backups with rsync.

https://scotch.io/tutorials/how-to-setup-ssh-public-key-authentication
John Simpson has a nice set of detailed instructions for setting this up as well.
Server Setup
On the machine you want to connect to, make sure the necessary SSH directory and key files are in the home directory of the user you are going to connect to the server as:

mkdir -m 700 ~/.ssh
touch ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys

Client
On the client, the machine you will be connecting to a server from, create public and private keys. If you want to use the key for automated tasks leave it empty, otherwise supply a pasphrase when prompted.

ssh-keygen -t rsa

Possible configuration options:

  • -b <ebits> - default is 2048, sufficient for most needs
  • -C <comment> - add comment to the key

The public key ~/.ssh/ir_dsa.pub needs to be copied to the server that you are going to connect to:

cat ~/.ssh/id_rsa.pub | ssh <username>@<server> "cat >> ~/.ssh/authorized_keys"

Then you should be able to connect to the server without entering a password:

ssh <username>@<server>

SSH Shortcuts
Edit ~/.ssh/config and add an entry for a server:

Host servername
  HostName www.servername.com
  User username
  #Port 22

You can now connect using the shortcut:

ssh servername

Technology:

Recent Updates

  • 5 days 1 hour ago
    1.27.2 update
  • 2 weeks 2 days ago
    Drupal 10/11 config
  • 2 weeks 3 days ago
  • PHP
    2 weeks 3 days ago
    PHP 8.3.11 and AlmaLinux
  • 2 weeks 4 days ago
    New version of Pound