Hello Guyz… :).. Today In this tutorial I’m going to manage the remote Ubuntu/Linux machines via SSH key pairs. First of all let’s assume there are two Ubuntu servers are available, those are called QA-Server and PP-Server. (Please note, these all commands are run on QA-Server Terminal)
In order to create new user on QA-Serever the server use the following bash commands are used on QA-Serever.
$ sudo useradd -m -s/bin/bash <username>
$ sudo passwd <username>
Under the username you can add whatever the username and then add a relevant password for the created user.
As the first step you need to generate a RSA key pair which includes public key and the private key. The following bash command is used to generate key pair.
$ ssh-keygen -t rsa
Then you will see the following questions, then answer those clearly. In questions you will ask the directory where to store the key pair, paraphrases, etc. I f you are not willing to enter a paraphrase, let the field blank and enter. Finally you will see the following output.
Enter file in which to save the key (/home/qauser/.ssh/id_rsa):
Created directory ‘/home/qauser/.ssh’.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/qauser/.ssh/id_rsa.
Your public key has been saved in /home/qauser/.ssh/id_rsa.pub.
The key fingerprint is:
The key’s randomart image is:
+–[ RSA 2048]—-+
Then we need to copy the id_rsa public key to the destination server, in my case I’m using PP-Server.
$ ssh-copy-id ppuser@PP-Server
Then you will get result like this.
Number of key(s) added: 1
Now try logging into the machine, with: “ssh ‘firstname.lastname@example.org′”
and check to make sure that only the key(s) you wanted were added.
Now you are eligible to login and execute bash commands on remote Ubuntu machines without passwords, as an example here is my loin.
$ ssh ppuser@PP-server “ifconfig”
Thank You….. 🙂