0

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

Problem

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

Question

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

1 Answer 1

3

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:

%ubuntu ALL=(root) NOPASSWD:PRIVCMDS

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:

ubuntu ALL=(root) NOPASSWD:PRIVCMDS

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .