Install SSH and and ssh-keygen for certificate-based authentication between two Ubuntu servers/hosts.
Install SSH:
$ sudo apt-get install openssh-server
Setup SSH with the main system admin account:
$ cd /home/myadmin/
$ ssh-keygen
(You don't have to use a password if not desired.)
Copy to the other Ubuntu server:
$ ssh-copy-id myadmin@ip.addr.other.server
< enter the myadmin password for the other server>
Confirm authentication now using just certificate:
$ ssh 'myadmin@ip.addr.other.server'
(no password prompt - you should now have SSH session on second server)
Root SSH Login:
Root SSH Login is not recommended but is required with various internal infrastructure products.
$ sudo -i
# vi /etc/ssh/sshd_config
(add the following line)
PermitRootLogin yes
<esc and wq> (to save)
# systemctl restart ssh
# passwd
<give root a password>
# exit
$ cd /home/myadmin/
$ ssh-keygen -t rsa
$ sudo ssh-copy-id -i /home/myadmin/.ssh/id_rsa.pub 127.0.0.1
(this machine)
$ sudo ssh-copy-id -i /home/myadmin/.ssh/id_rsa.pub ip.addr.other.server
$ sudo cat /home/myadmin/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys
Confirm root logins:
$ sudo ssh root@127.0.0.1
$ sudo ssh root@ip.addr.other.server
Both should be successful again.
previous page
|