Steps to install a local SSH key pair and deploy on a remote host

1) Navigate to zabbix user:
su - zabbix -s /bin/bash
2) See it's "zabbix":
whoami
3) Ensure this is "zabbix_server", we should be able to see hundreds of processes:
ps auxww | grep zabbix_server
4) Generate a new SSH pair (leave all defaults; need to hit enter 3 times):
ssh-keygen
It will output data like:
Generating public/private rsa key pair.
Enter file in which to save the key (/var/lib/zabbix/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /var/lib/zabbix/.ssh/id_rsa.
Your public key has been saved in /var/lib/zabbix/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:I+KY/JYwtHBKrbzP5lCV9YyJGktPAugyoz+gz1ErVcY zabbix@something.fqdn.lan
The key's randomart image is:
+---[RSA 3072]----+
|..     .         |
|. .  .+ =        |
|. .+ =Eo o       |
|=o+.Oo           |
|=B.=+.. S        |
|++=* o . .       |
|.+Boo.           |
|.o==o            |
| .**.            |
+----[SHA256]-----+
5) Push the key to the remote host:
ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.88.15
Enter the password last time
6) Test if we can execute a command on a remote host without providing a password logging in:
ssh 'root@192.168.88.15' 'hostname'
ssh 'root@192.168.88.15' 'ls -1'
ssh 'root@192.168.88.15' 'systemctl status zabbix-proxy'
7) exit "zabbix" user.
exit

No comments: