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.