Wednesday, November 23, 2011

sudo without password

  Our team has encountered a problem with restarting tomcat server on remote Ubuntu machine.

  We have a trusted SSH connection between our machines and the remote one, so we don't have to use passwords when accessing remote machine. However, we had to use a password for restarting tomcat server with this command:



  As we are using secure passwords, it was quite annoying to copy/paste this password all the time. Here is the solution that we figured out.

  Go to remote machine and run following command:



  And add something similar to the end on file:



  Save changes (Ctrl+X) and logout/login

  Now all members of tomcat6 group should be able to restart the server without entering password.

  It's also nice, that you can provide not only the command that does not require password, but also arguments. In our case, it allowed to simplify tomcat restart while still requiring password for shutting down the server.