ssh authentication


This is to present the way to setup an ssh authentication from one machine to another, without need for using passwords.
I will call "A" the box you use to run monitoring tool, I will call "Monitored" the box you want to monitor.
I will also assume you use an account called "admin" to run this tool. That account should exist both on "A" and on "Monitored"

1. Check if public key exists on A.
On "A", login as "admin" and check if ~/.ssh/identity.pub exists
If it exists, go to 2. now
If it doesnt, run "ssh-keygen" and enter an empty passphrase. Keep default location for saving keys.

2. Copy public key to appropriate location on "Monitored"
Copy the file /home/admin/.ssh/identity.pub from "A" to /home/admin/identity.pub on "Monitored"
on Monitored, run "cat /home/admin/identity.pub >> /home/admin/.ssh/authorized_keys" Now the admin account on "A" is authorized to login through ssh to "Monitored" without entering a password.

3. Optional - lock admin account access on both "A" and "Monitored" machines.
If you use an admin account on your boxes, probably you dont want anyone to be able to login to them on that account, using a password. Ssh keys are certainly enough for the scope of this project. So you can - and it is indeed a good idea to do so - lock password-authenticated access to both boxes on account "admin".
To do so, login as root and edit the /etc/shadow file
You will see a line in the file that will look like this :
admin:$1$jvKZ$Kgfg9mdhdzdXQggPWt1:11422:0:99999:7:::
Change it and replace the second field (separator is ":") with just a "*". Your new line will look like this:
admin:*:11422:0:99999:7:::
Now it is impossible to login to that box as "admin" if you are not referenced in the authorized_keys