1

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?

0

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

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.
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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.