Categories
Uncategorized

ssh key with root

Copy ssh key from clientsvr to backupsvr

From clientsvr, generate ssh key, accept al defaults

su
cd ~
ssh-keygen

On backupsvr, edit the ssh confile, /etc/ssh/sshd_config

replace
PermitRooLogin no
With
PermitRootLogin yes
PermitRootLogin without-password

Reload sshd daemon:

systemctl restart sshd

Back to clientsvr

ssh-copy-id -i root@backupsvr
ssh root@backupsvr

Back to backupsvr:

emacs /etc/ssh/sshd_config
remove
PermitRootLogin yes
exit emacs
reload sshd
systemctl restart sshd

==== If ssh_copy-id is not available ====

From local host (from client)

cat .ssh/id_rsa.pub | ssh myRemoteServer 'cat >> .ssh/authorized_keys && echo "Key copied"'