How to use a Private key for SSH authentication

Linux Help 

What’s a private key?

Even the most complex passwords cannot match the cryptographic strength of private keys. With SSH, private keys significantly improve security by relieving users of the burden of remembering complex passwords (or worse yet, writing them down).

Let’s first Open a terminal and generate a private key.

Step 1 : Check to see if you already have an SSH key.

$ ls ~/.ssh

Output:

Step 2 : Create SSH key.

$ ssh-keygen

Output:

– The command will prompt you for a file name. By default, the ssh key pairs are stored as id_rsa and id_rsa.pub for private key and public key, respectively.

$ Enter file in which to save the key (/home/ubuntu/.ssh/id_rsa):

To use the default filename, press ENTER and proceed.

In the next part, enter a passphrase to secure your key pairs. You can skip this by pressing ENTER.

$  Enter passphrase (empty for no passphrase):

$  Enter same passphrase again:

Step 3 : Copy public key to the remote host.

$ ls ~/.ssh

Output:

To use the SSH key pair you created, we must first copy the public key to the remote server. Fortunately, OpenSSH includes the ssh-copy-id function to do this.

$ ssh-copy-id remote_server_user@remote_server_ip

Step 4 : SSH using The Private Key.

$ ssh remote_server_user@remote_server_ip

You have now successfully utilized SSH key-based authentication. By eliminating password login, you may provide an extra degree of protection.

Conclusion

This tutorial has shown you how to create SSH key pairs and copy the keys to remote hosts. The steps mentioned above allow you to authenticate SSH sessions without using a password. Furthermore, you may control numerous servers at the same time with a single key pair.

Recommended Posts

How to Start Using a Web Hosting Account

Starting with a web hosting account is an essential step in launching your online presence. Whether you’re setting up a personal blog, an e-commerce website, or a professional portfolio, a hosting account serves as the foundation. Here’s a comprehensive guide to help you get started: Step 1: Choose the Right Hosting Plan Before diving into […]

Linux Help 

5 Linux commands to check free disk space

Keeping track of disk utilization information is on system administrators’ (and others’) daily to-do list. Linux has a few built-in utilities that help provide that information. Linux df command The df command stands for “disk-free,” and shows available and used disk space on the Linux system. df -h shows disk space in human-readable format df -a shows the file system’s […]

Linux Help