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:
Log in as “ubuntu”
ssh ubuntu@your-server-ip
Edit the SSH Configuration
sudo vim /etc/ssh/sshd_config
Modify SSH Configuration
PermitRootLogin prohibit-password
Replace it with:
PermitRootLogin yes
Edit the authorized_keys file
sudo vim /root/.ssh/authorized_keys
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"
Log in as root
ssh root@your-server-ip