How to Set Passwordless SSH Login on RHEL 8

With the release of RHEL 8, you get to experience what the real product will be like and test some of its functionalities. If you are eager to test RHEL 8 you can signup for free and download RHEL 8.

You can review our RHEL 8 installation tutorials on the links below.

To easily understand this, I will be using two servers:

  • 192.168.20.100 (kerrigan) – server from which I will be connecting
  • 192.168.20.170 (tecmint) – my RHEL 8 system

In this tutorial, you are going to learn how to set up passwordless SSH login on your RHEL 8 install using ssh keys. Make sure the Open-ssh server should already installed on your system, but in case it is not, you can install it by issuing the following yum command:

# yum install openssh-server

Step 1: Generate SSH Key on 192.168.20.100 (kerrigan)

On the system, from where you will be connecting to your RHEL 8 system, generate a new ssh key pair. This can be done by using the following command:

# ssh-keygen

You can configure a meaningful name for the file or just leave it to the default one. When asked for a passphrase, simply press “enter” and leave the password empty.

Generate SSH Keys on RHEL 8
Generate SSH Keys on RHEL 8

Step 2: Copy SSH Key to 192.168.20.170 (tecmint)

Copying the key is a simple task that can be completed by using the ssh-copy-id command as shown.

# ssh-copy-id -i ~/.ssh/id_rsa.pub user@remote-server

When prompted for the remote user’s password, simply enter it. This will create the “.ssh” directory if missing and the authorized_keys file with appropriate permissions.

Copy SSH Key to RHEL 8
Copy SSH Key to RHEL 8

Step 2: Test SSH Passwordless Login from 192.168.20.100

Now that we have the key copied to our remote server, we can test the connection. You should not be asked for a password:

# ssh -i ~/.ssh/id_rsa  user@remote-server
Test SSH Passwordless Login
Test SSH Passwordless Login

In this tutorial, you learned how to SSH to your RHEL 8 system using a passwordless ssh key. I hope the process was easy. If you have any questions, please post them in the comment section below.

Two small things before you go

If something didn’t work on your setup, leave a comment and tell me which distro and version you’re on. I read every one, and most of these articles got better because a reader pointed out what was missing.

And if it did work, share it. TecMint has stayed free for 14 years because people pass these articles around, and that traffic is what pays for writing the next one.

Leave a comment
Get two free Linux courses

Learn the Linux basics with two free courses and join 34,000+ readers getting practical TecMint tutorials and selected Pro TecMint articles every week.

Pro TecMint
Get lifetime access for $99

If you want to go beyond the free tutorials, Pro gives you 18 courses, 5 ebooks, and every future course I add. One payment, lifetime access, no renewals.

Marin Todorov
Marin Todorov
Contributor
About the author

I am a bachelor in computer science and a Linux Foundation Certified System Administrator. Currently working as a Senior Technical support in the hosting industry. In my free time I like testing new software and inline skating.

3 Comments

Leave a Reply
  1. So I have used this method for a previous Beowulf Cluster (Ubuntu 16.04). I wanted to switch to Scientific Linux. I have successfully completed the steps and gotten the passwordless connections. HOWEVER: the connection via port 22 gets ‘refused’ and I have no idea how to bring these back to life without starting all over. Can you help?

    Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.