This article will guide how to configure SSH key-based Authentication in Linux VPS or Dedicated Server
In SSH Key-Based Authentication, all we do is generate public authentication key and copy the key over Linux VPS or dedicated server to connect without typing the password.
Below are the steps on how to execute SSH Key-Based Authentication in Linux VPS or dedicated server.
- Open the terminal of your local Linux machine.
- The first step is to create key-pair on the local machine.
Enter the command ssh-keygen.
Enter file in which to save the key (/home/andrew/.ssh/id_rsa): (Press “Enter”)
- If the key was already present then you may see:
Overwrite (y/n)? (press “y” and then enter)
- Then you should see the following output:
Enter passphrase (empty for no passphrase): (press “Enter”)
Enter same passphrase again: (press “Enter”)
- To copy the key of your Linux server, enter the following syntax.
ssh-copy-id (username)@(IP of your Linux VPS or dedicated server) -p (port no.).
- Then it will prompt for a password, Enter the VPS/Dedicated server’s password.
It will copy the contents of your ~/.ssh/id_rsa.pub key into host server’s authorised_keys.
- The process is completed successfully, now you can SSH from the local machine to your VPS/dedicated server without typing the password.