If you’ve encountered the SSH error message ‘Please login as the user ‘ubuntu’ rather than the user ‘root’?’ and you need root user access, follow these steps:

  1. Log in as “ubuntu”

    ssh ubuntu@your-server-ip
  2. Edit the SSH Configuration

    sudo vim /etc/ssh/sshd_config
  3. Modify SSH Configuration

    PermitRootLogin prohibit-password

    Replace it with:

    PermitRootLogin yes
  4. Edit the authorized_keys file

    sudo vim /root/.ssh/authorized_keys
  5. Remove or comment out the restrictive line

     no-port-forwarding,no-agent-forwarding,no-X11-forwarding,command="echo 'Please login as the user \"ubuntu\" rather than the user \"root\".';echo;sleep 10"
  6. Log in as root

     ssh root@your-server-ip