On a remote server I can execute a certain command only via "sudo". The authentication is done via a certificate. So when I login via SSH by a bash script, python, ruby or something else, how can I execute a certain command with sudo?
1 Answer
The proper way of doing this is using a configuration management solution, like ansible, You can use become directive to run script/command with sudo privileges from a remote client.
If there is only one box or you need to schedule, you can use /etc/crontab and run it with root user at desired interval.
2 Comments
Farhad Farahi
You can schedule with root privileges, Or use
sudo python script.py from the command line. or ssh with root user to the remote box.Kumakaja
none of that will work. it's not schedulable. the python script is executed by a local user on a local computer. and logging as a root isn't what I need.