Saturday, August 1, 2015

Stuck on password even though used --disabled-password option in ubuntu




I created a user in aws ec2 with:
ubuntu$ sudo adduser --disabled-password user1



per instructions from:
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/managing-users.html



After I ssh in as user1 (by first creating .ssh, adding auth keys, etc.), I try to su to root (I do know root's password) with:
user1$ su -



I get prompted with:
[sudo] password for user1:



I tried hitting just the enter key, since I created user1 with --disabled-password in the first place, but I get Authentication error.




In every other Linux/Unix system I've been on and having root's password, I'm always able to switch to root user with just 'su' or 'su -' from any other user and never had to enter the password from the account I'm switching from.



Any way to recover from this? Is there some default password that gets assigned for reason when
--disabled-password option is used with the adduser command?



I can no longer ssh into 'ubuntu' account either for some reason.



Also, I did create user1 via the AMI control panel and downloaded Access Key and Secret Access Key Id's. Are these any help here? Thanks.


Answer



You cannot use su to become root user in Ubuntu (unless you enable it, but it is not recommended). You should use sudo instead:





By default, the Root account password is locked in Ubuntu. This means
that you cannot login as Root directly or use the su command to become
the Root user. However, since the Root account physically exists it is
still possible to run programs with root-level privileges. This is
where sudo comes in - it allows authorized users (normally
"Administrative" users; for further information please refer to
AddUsersHowto) to run certain programs as Root without having to know
the root password.




This means that in the terminal you should use sudo for commands that
require root privileges; simply prepend sudo to all the commands you
would normally run as Root.




Reference: https://help.ubuntu.com/community/RootSudo



To answer your last question, IAM users don't have anything to do with OS users.


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...