Adding a new user with sudo privileges is pretty simple.
Add the user with the
adduser script. It will ask you a few things about the new user, and prompt for a new password.
sudo adduser john
Then to give sudo rights to it, edit the sudo config file as the
sudo sudoedit /etc/sudoers
Duplicate the last line, but changing “rails” to whatever your new username is:
rails ALL=(ALL) ALL john ALL=(ALL) ALL
WARNING: If you make an error in this file you could lock yourself, and us, out of root access. The only solution then is for us to boot into rescue mode and fix the file manually for you and this work would be chargeable. The
sudoedit command should make sure you don't make any obvious mistakes, but double check your work!
Now you need to configure SSH to allow access for the new user. Edit the ssh config at
/etc/ssh/sshd_config and add a new allow users line at the bottom. You'll see the other user access lines in there:
AllowUsers rails@* AllowUsers john@*
Then reload ssh:
sudo /etc/init.d/ssh reload
Our Brightbox GEM Capistrano recipes do assume that you're using the
rails user in the usual home directory though. Changing the user and home directory will cause problems for it, but if you're using your own recipes, you can obviously customize them however you wish.