RedHat 7/8 – SSH Key-Based Authentication

You can configure an SSH Server to allow you to authenticate without an password by using key-based authentication (private-public key)

To do this, you will need to generate a matched pair of cryptographic key files (Private and public key). The private key file is used as authentication credential (like a password), public key is copied to the destination server that you want to connect to, and is used to verify the private key.

To create a key pair, use the ssh-keygen command. By default, private key (id_rsa) and public key ( will save at your home directory .ssh folder (~/.ssh/)

Step 1 – On source server, open a root shell

Step 2 – Type ssh-keygen. If you want to set the passphrase for the private key, you may do so, else just press Enter to complete the SSH Keygen process.

Step 3 – Share the Public Key with Destination Server

Before key-bases authentication can be used, the public key need to copy to the destination server. The ssh-copy-id command copies the public key of the SSH Keypair to the destination server.


ssh-copy-id -i .ssh/ user@remotehost

After copying the public key, verify that it can be used for authentication. To do this, just ssh to the destination server, you should now authenticate without having to enter the login password.

Leave a Reply

Your email address will not be published. Required fields are marked *