Setting up a rails server (Ubuntu 12.10) on DigitalOcean and I want a non-root user to run some deployment commands with root access by prefixing sudo
to the command and entering a password. I thought I could edit visudo
like below, but permissions is denied. Am I missing something?
Defaults env_reset
Defaults mail_badpass
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
# User privilege specification
root ALL=(ALL:ALL) ALL
nonrootuser ALL=(ALL:ALL) ALL
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL
I made nonrootuser a member of the deployers
group in case I have multiple deployment agents in the future. That group isn't called out in visudo, but I don't know if it's relevant, so I'm mentioning it here.
Commands like this fail from my dev box (not the server.) I would expect this to append the contents of my dev box public key to the server's authorized_keys file on the server after prompting for nonrootuser password. Actual result is permissions denied.
cat ~/.ssh/id_rsa.pub | ssh -p 12345 [email protected] 'cat >> ~/.ssh/authorized_keys'
I've attempted rebooting the box entirely, and still no change. I've also tried sudo cat...
in my piped command with no results.
sudo
anywhere in it…sudo cat...
as well. I was somehow able to solve this by deleting the user and recreating. Somehow, that worked.