Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am setting up a server in Amazon EC2. I created an image from Amazon's provided images of Ubuntu x64 12 LTS. My goal is to set up a secure svn server there, where access is only possible by IP address, SSH and certificates. I also need to migrate existing public keys from an old server.

Having played with permissions I managed to add another user account, but somehow locked myself (ubuntu) out of the server. Remote root log in is disabled, and I locked ubuntu user. Ooops.

This is why I would like to create a temporary user account, say FOO. If I lock it out, I still have ubuntu. I would like this user to have the same privileges as ubuntu, i.e. I want to do something like

sudo apt-get install subversion


When I created a new user and sshed to the server, the server always asked me for sudo password, when I called anything starting from sudo


How to add a new user with the same privileges as ubuntu, so I can call sudo ... without being prompted with a sudo password?

This is what I have done so far:

# add user
sudo useradd -m -G ubuntu,adm,dialout,dip,plugdev,netdev,admin FOO

# add public key for ssh
sudo -s
cd /home/FOO
mkdir .ssh
cd .ssh
nano authorized_keys

    Generate certificate in PuttyGen
    Add public key to authorized_keys

#set permissions for ssh to work
chown -R FOO /home/FOO/.ssh
chgrp -R FOO /home/FOO/.ssh
chmod 0755 /home/FOO
chmod 755  /home/FOO/.ssh
chmod 644  /home/FOO/.ssh/authorized_keys

#add FOO to sudoers
sudo usermod -aG sudo FOO

##check permissions
ls -lha /home/FOO
ls -lha /home/FOO/.ssh
share|improve this question

That's easy. I'll refer to another answer of mine and give the gist for your case. My other answer was: When Ubuntu asks for an admin user's password, how does it decide which administrative user to ask for?

The gist is to edit /etc/sudoers and add a Cmnd_Alias (say PRIVCMDS) for the command you want to allow and then something like this in sudoers:


But please read through my complete answer to the other question.

The above is for the system group named ubuntu. If you wanted the same for the user named ubuntu it would read:

share|improve this answer

Based on @0xC0000022L answer I edited /etc/sudoers file:

# edit /etc/sudoers

# find this line and add NOPASSWD before the last ALL
# Allow members of group sudo to execute any command

This is a temp measure so I don't lock up my single remotely accessible user. I will remove a FOO user account and fix sudoers file once set up is complete. Have a look at other options mentioned in @0xC0000022L answer.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.