SSHing to the EC2 server through gives an error. Please log in as user ec2, not root.

Question as a headline. Why is this, I used the ssh command: ssh -i mykey.pem root@xxx-xxx-xx-xx-xxx.compute-1.amazonaws.com But I get this error, I can not find anything in google. What am I doing wrong?

+52
ssh amazon-ec2
Nov 20 '10 at 0:17
source share
5 answers

You are logged in as ec2-user , as Klaus suggested:

 ssh -i key.pem ec2-user@host 

... and then you use sudo to run the commands. For example, editing the /etc/hosts , which is owned by root, requires root privileges for it: sudo nano /etc/hosts .

Or you run sudo su to become the root .

+73
Nov 20 2018-10-10T00:
source share

By default, the root user cannot log in, but you can use ec2-user as indicated by others.

After logging in using ec2-user you switch to root and change the SSH configuration.

To become root, you run:

 sudo su - 

Edit the SSH daemon configuration file /etc/ssh/sshd_config , for example. using vi and replace the PermitRootLogin entry with the following text:

 PermitRootLogin without-password 

Reload the SSH daemon configuration by doing:

 /etc/init.d/sshd reload 

The message Please login as the ec2-user user rather than root user. displayed Please login as the ec2-user user rather than root user. , because the command is executed when entering the system with the private key. To remove this command, edit the ~/.ssh/authorized_keys file and remove the command parameter. The string must begin with a key type (for example, ssh-rsa).

(*) Do it at your own risk. I recommend that you always open the console just in case you cannot log in after making configuration changes.

For reference, you can read the manual pages:

 man sshd_config man sshd 
+60
Dec 02 '10 at 15:18
source share

I ran into a similar issue when setting up a hadoop cluster on Amazon ec2.

My head node should have root ssh access to every worker / slave node. I connected the connections by adding an IP address, a private address, and an alias to /etc/hosts/ each subordinate node. (I get this data by running the command echo -e "`hostname -i`\t`hostname -f`\talias-name" , where alias-name is what I call each node ( head or n1 for example). Then I put this output for each node in each node /etc/hosts .

The problem that I am facing is that when I type ssh n1, being in my head node, in ssh in my first sub node, I get the same error message: Please login as the use "ec2-user" rather than the user "root". Therefore, after some research, I figured out how to fix it.

At first:

  • ssh to your server. non-root access (ec2-user) is great here.
  • Then su - your root path. Now vi /etc/ssh/sshd_config and un-comment line is PermitRootLogin yes .
  • Quit vi.
  • Now restart the ssh daemon by typing service sshd stop , then service sshd start .

Second:

  • Now, here is the part that I had to dig,
  • run vi /root/.ssh/authorized_keys
  • Comment everything up to ssh-rsa. Just put # at the beginning of the contents of the file, before no-port-forwarding ... and press enter on ssh-rsa to move it to the next line (this way you don't have to delete anything if you want to backtrack).
  • exit vi editor

Now you can log in to root without an error message.

Also, if you use aliases to configure the cluster; Repeat the same steps for each node. First ssh to use the ec2 user, follow these steps. After adding the IP address, private address, and alias information to the /etc/hosts you can use ssh for each root root using the alias name, for example ssh n1 .

The following tutorial is here: https://www.youtube.com/watch?v=xrxQXfE7t9A

But he did not discuss the root entry issue.

Hope this helps! It worked for me.

* Keep in mind that I was not worried about security. This is just a practice / dev setup.

+9
Aug 04
source share

I think it just asks you to log in with a different username. Do you have a user called ec2-user ? If yes, try this instead:

 ssh -i mykey.pem ec2-user@xxx-xxx-xx-xx-xxx.compute-1.amazonaws.com 
+7
Nov 20 '10 at 0:20
source share

Modify / etc / ssh / sshd_config and verify that it is installed:

PasswordAuthentication yes

Then reboot SSH:

systemctl reload sshd.service

Now you can log in as users other than ec2.

0
May 05 '12 at 17:47
source share



All Articles