Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Amazon EC2 Root login

I'm trying to enable root login for my EC2 instances. I know I could use su or sudo, but I need to be able to ssh'ing into my server as root because the Jenkins EC2-Plugin requires root access.

I already found some solutions during my web search but they all didn't work:

  • PermitRootLogin in /etc/ssh/sshd_config
  • Copy authorized_keys to root's .ssh-Folder

This link seemed to be quite useful but also didn't work: http://teknika.tumblr.com/post/5416465911/jenkins-ec2

like image 769
Tom Ferguson Avatar asked Sep 13 '11 19:09

Tom Ferguson


People also ask

How do I login as root in ec2?

You can enable password and root login using the following procedure: Update the cloud-init configuration file to allow root access and password login. Update the authorized_keys file. Update the sshd_config file to enable password authentication and root login.

What is the root password for AWS ec2?

AWS doesn't grant root access by default to EC2 instances. This is an important security best practise. Users are supposed to open a ssh connection using the secure key/pair to login as ec2-user. Users are supposed to use the sudo command as ec2-user to obtain elevated privileges.

How do I log into my AWS root account?

If you're a root user, open the Sign in page, select Root user, and sign in using your AWS account root user credentials. Sign in using a custom URL https://account_alias_or_id.signin.aws.amazon.com/console/. You must replace account_alias_or_id with the account alias or account ID provided by the root user.

Is ec2-user root user?

For a RHEL AMI, the user name is ec2-user or root . For a SUSE AMI, the user name is ec2-user or root . For an Ubuntu AMI, the user name is ubuntu . For an Oracle AMI, the user name is ec2-user .


Video Answer


2 Answers

Refer to the following to set root login:

sudo -s (to become root) vi /root/.ssh/authorized_keys 

Delete the lines at the begining of the file until you get to the words ssh-rsa.

vi /etc/ssh/sshd_config 

Set the variable PermitRootLogin to PermitRootLogin without-password (without quotes)

sudo /etc/init.d/sshd restart 
like image 187
Thiyagarajan Varadharaj Avatar answered Sep 21 '22 06:09

Thiyagarajan Varadharaj


edit /etc/ssh/sshd_config

  • Comment out the line "PermitRootLogin"
  • Comment out the line "PasswordAuthentication no"

Then restart the ssh service

/sbin/service sshd restart 
like image 28
dmohr Avatar answered Sep 23 '22 06:09

dmohr