I launched an Ubuntu 18 instance on EC2.
I connected to the server using ubuntu user.
I created a new user named newuser and added it to the sudo group.
Then I ran:
rsync --archive --chown=newuser:newuser ~/.ssh /home/newuser
in order to let the new user to connect to the server directly.
When I'm trying to connect to the server using the new user I'm getting the following error:
Using username "newuser".
Authenticating with public key "imported-openssh-key"
Please login as the user "ubuntu" rather than the user "root".
I get the same error from both MobaXterm and PuTTY.
As tritium_3 suggested, I had to edit .ssh/authorized_keys, to remove the following text:
and keep the ssh-rsa and key that comes after it.
However, the
rsync
command had copied the file to the new user, so I had to edit the file that was under /home/newuser/.ssh/authorized_keys rather than /root/.ssh/authorized_keys.there is a command inside authorized_keys as follows.
remove this line and keep the ssh-rsa and key that comes after it.
save the file then try again.
The proper way to address this is by using ssh's
-l
flag. Not by tampering with warning messages.Example:
Not working:
Working:
Note: You are elevating your permission to execute access to the
.pem
file. Which means you are probably 'root'. The SSH connection wants you to login with that machine's user name in this case "ubuntu". So, passing the "-l" flag allows us to set that value.Hope this helps!
Because it kept on annoying me I created this oneliner: