SSH, an acronym for Secure Shell, serves as a robust mechanism to establish secure communication between your system and remote machines across the internet. Analogous to a discreet cryptographic protocol, SSH ensures a confidential and authenticated connection between devices. This comprehensive guide is designed to clarify the procedure for configuring SSH keys on Ubuntu 20.04, a prominent variant of the Linux operating system.
First, you need to create your secret keys. This is like making a special pair of keys that only your computer and the other one can understand. Here’s how you do it:
After all this, you’ll see some text on your screen. These are your secret keys, so keep them safe.
Now, you need to provide your server with the key. This is the public key, which is safe to share. There are a few ways to do this:
Your computer might already have a tool called `ssh-copy-id` installed. This tool can do the job easily. Just type this command in your terminal:
```bash ssh-copy-id username@remote_host ```
It will ask for the password of the remote computer. Type it in, and it will copy your public key there.
If the tool isn’t there, you can do it manually. Here’s how:
```bash cat ~/.ssh/id_rsa.pub ```
It will show you your public key. It starts with `ssh-rsa` and has a long string of letters and numbers.
```bash ssh username@remote_host ```
It will ask for a password. Enter it.
```bash mkdir -p ~/.ssh && touch ~/.ssh/authorized_keys && chmod -R go= ~/.ssh && nano ~/.ssh/authorized_keys ```
If it asks you about the fingerprint, just say yes.
Now that your secure connection is set up, you can log in without a password.
```bash ssh username@remote_host ```
For even more security, you can turn off password login. This means only your secret keys can get you in. Here’s how:
```bash sudo nano /etc/ssh/sshd_config ```
```plaintext PasswordAuthentication no ```
```bash sudo systemctl restart ssh ```
```bash ssh username@remote_host ```
You’ve now set up SSH keys, allowing you to log in securely, and even disable password logins for extra safety.
Have additional questions? Search below: