Allow root access via SSH on CentOS

If you see the message: “Please login as the user “centos” rather than the user “root”  we need to allow root access via SSH.

  • Login as the user “centos”:
    # ssh -i PrivateKey.pem centos@Floating-IP-Address
  • Change to root:
    # sudo -s
  • Edit the file “/root/.ssh/authorized_keys”
    # vi /root/.ssh/authorized_keys
    and keep it only contains the key  (starts with “sh-rsa”) without the restrictions that exist at the begining of the file.
  • Open the sshd_config # vi/etc/ssh/sshd_config
    and uncomment the line “PermitRootLogin yes”
  • Restart SSH daemon:
    # systemctl restart sshd

Now you can SSH as root to your instance, high five!

© 2021 - FreshLondon