Mastering Remote Access: How to Use SSH Keys with Your Ubuntu Server
Ditch the Password for More Secure Server Access
When you manage an Ubuntu server, you’ll be using SSH (Secure Shell) to connect and run commands. While you can use a password, the ‘Ubuntu System Administration Guide’ strongly recommends a more secure and convenient method: SSH keys.
How SSH Keys Work
An SSH key pair consists of a private key, which you keep secret on your computer, and a public key, which you place on the server. When you connect, the server uses the public key to verify that you are in possession of the corresponding private key. This is significantly more secure than a password, which can be guessed or brute-forced.
Generating and Using Your Keys
Creating a key pair on your local machine is simple with the `ssh-keygen` command. Once generated, you can easily copy your public key to the server using the `ssh-copy-id` utility:
ssh-copy-id your_username@your_server_ip
After entering your password one last time, your key will be installed. From then on, you can log in to your server securely without needing to type a password.
This post is based from content of the book Ubuntu System adminstration guide. And the book can be found here https://www.amazon.com/stores/Mattias-Hemmingsson/author/B0FF5CQX13