-2

I need to set the password for root user when sudo su -, ubuntu user should login via ssh key only.

#ssh -i server.pem ubuntu@example.com

ubuntu@example.com:~$ sudo su - --> should prompt the password of root

root@example.com:~#   --> and also I have setup the password for root, but it does not prompt the password.


root@example.com:/etc/sudoers.d# cat 90-cloud-init-users 
# Created by cloud-init v. 0.7.5 on Mon, 12 Sep 2016 10:23:06 +0000

# User rules for ubuntu
ubuntu ALL=(ALL) NOPASSWD:ALL

# User rules for ubuntu
ubuntu ALL=(ALL) NOPASSWD:ALL

# User rules for ubuntu
ubuntu ALL=(ALL) NOPASSWD:ALL
13dimitar
  • 2,360
  • 1
  • 12
  • 15
Jai
  • 1
  • 3
  • 1
    [You already asked this question](https://serverfault.com/q/854191/153161). If you are not satisfied with the answers you received, please clarify the original question. – Michael - sqlbot Jun 07 '17 at 12:11

1 Answers1

0

Modify the settings for ubuntu user in sudoers file like this:

ubuntu ALL=(ALL) ALL

When you're logged in with ubuntu user and do a sudo -i, you will get prompted for the password of ubuntu user.

If you do su, you will get prompted for root's password.

13dimitar
  • 2,360
  • 1
  • 12
  • 15