EC2 login as EC2 user other than root

Solution 1:

The "root" account has been disabled. Where you entered "root" before, enter "ec2-user" instead and you'll be in. Once you're in, if you need to run a command as root, put "sudo" in front of the command.

eg:

sudo nc -l 80

or to get a console as root:

sudo bash

Solution 2:

If you want to be able to login as root into a prebuilt Amazon AMI, you need to do two things, these commands should be run as root.

  1. Edit the /etc/ssh/sshd_config file and change the line that says 'PermitRootLogin No' to 'PermitRootLogin without-password'. Then restart the sshd client with 'service sshd restart'. Be careful, if you screw up the sshd file, it is possible you will only have your current ssh session to fix it, so always test any changes with a second session.

  2. Edit the /root/.ssh/authorized_keys file. The first (and only) entry starts with 'command ... sleep 10; ssh-rsa [big long key]'. If you remove the text from the beginning of the line until where it says ssh-rsa, you will be able to login as root via SSH with your Amazon keypair.

Solution 3:

Just insert ec2-user in the data section of your putty configuration.

Solution 4:

It sounds like that's something specific to the AMI you're loading your EC2 instance from. Most AMI's use root as the default user setup but that is dependent on how the AMI instance. In most cases this is simply root and it leaves you to create any additional users. I for instance have root installed in the AMI and have the SSH key installed on boot-up and then allow other users to be configured via Puppet. If you built your AMI with SSH configured to disallow root login then you would obviously need an alternative user to be setup so you could log in successfully.

Solution 5:

I noticed the solution to this problem was in putty, where you put your long connection name like:

ec2-50-11-111-111.compute-1.amazonaws.com

you can use

[email protected]

and that error goes away and you are logged in as whatever username you put in front of the @ sign