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:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo service tomcat6 restart |
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:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo visudo |
And add something similar to the end on file:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%tomcat6 ALL=(ALL) NOPASSWD: /usr/sbin/service tomcat6 restart |
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.