Amazon EC2 Root login

53,917

Solution 1

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

Solution 2

Try this when you authenticate with your key:

$user@instance: sudo su

or assign a password with:

$user@instance: sudo su passwd

and change the password to enter with sudo su.

Solution 3

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

Solution 4

You need to edit file : /etc/ssh/sshd_config and restart ssh service .

  1. If you want to login using keys change as below :

    PermitRootLogin yes
    RSAAuthentication yes
    
  2. If you want to login using password , change as below :

    PermitRootLogin yes
    PasswordAuthentication yes
    

Solution 5

  1. ssh into EC2 as a normal user

  2. sudo su
    
  3. cd ~
    
  4. Edit the authorized_keys

    vim .ssh/authorized_keys
    
  5. remove the part which is not the key make sure the file will start with

    ssh-rsa ............................

  6. Save the file and try to login as a root

    ssh root@servername
    
Share:
53,917
Admin
Author by

Admin

Updated on July 09, 2022

Comments

  • Admin
    Admin almost 2 years

    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