Monitor other linux stations through SSH, passwordless commands

The proxy server is with IP address:
10.1.10.16
Destination server to monitor is with IP:
10.1.10.17
Generate SSH key:
ssh-keygen -t rsa -b 2048
This will show:
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:uqqJUWI2MGfgvXQlIdWX48FvJxvOlCukwYhGirDbCU0 root@zabbix.pro
The key's randomart image is:
+---[RSA 2048]----+
|.  ..+o.. .      |
|o.E.. o. *       |
|===o..o o + .    |
|==ooo. o o B .   |
|.Boo    S = *    |
|+o+    o . =     |
|.     .   .      |
| o .   .         |
|. o....          |
+----[SHA256]-----+
Copy public key to the home directory of destination station:
scp ~/.ssh/id_rsa.pub root@10.1.10.17:~
a password will be required to successfuly complete the command.

Now log in to destination station:
ssh root@10.1.10.17
A password will be required! Append the the SSH allowed_hosts file with the new public key:
cat id_rsa.pub >> ~/.ssh/authorized_keys
see how much keys are actually installed:
cat ~/.ssh/authorized_keys
Turn on SSH agent if it is not running:
ssh-agent
Exit remote station:
exit
try again authorize:
ssh root@10.1.10.17
This time the password will not be prompted.

No comments: