On the host where the cron job is
ssh-keygen -t rsa -b 4096
No password
Cd ~/.ssh 760708 -rw-------. 1 root root 3401 May 14 04:34 id_rsa
760710 -rw-r--r--. 1 root root 757 May 14 04:34 id_rsa.pub (copy to remote server)
scp ~/.ssh/id_rsa.pub root@192.168.1.22:/root/.ssh/uploaded_key.pub
On the remote server
cat ~/.ssh/uploaded_key.pub >> ~/.ssh/authorized_keys
cat ~/.ssh/authorized_keys
chmod 700 ~/.ssh/
chmod 600 ~/.ssh/*
On the host where the cron job is
ssh root@192.168.1.22
Check if you can login without password
On the remote server (for disableling password authentication)
sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
sudo vim /etc/ssh/sshd_config
unkommend PasswordAuthentication yes and replace yes with no
sudo service ssh restart
----------------------------------------------------------------------------------------------------
#Easy way to do it
On the host where the cron job is
ssh-keygen -t rsa -b 4096
No password
Cd ~/.ssh
760708 -rw-------. 1 root root 3401 May 14 04:34 id_rsa
760710 -rw-r--r--. 1 root root 757 May 14 04:34 id_rsa.pub
ssh-copy-id root@192.168.1.22