Running python script as another user

后端 未结 3 1124
南旧
南旧 2021-01-04 11:26

On a Linux box I want to run a Python script as another user.

I\'ve already made a wrapper program in C++ that calls the script, since I\'ve realized that the owners

3条回答
  •  情书的邮戳
    2021-01-04 12:07

    Use the command sudo.

    In order to run a program as a user, the system must "authenticate" that user.

    Obviously, root can run any program as any user, and any user can su to another user with a password.

    The program sudo can be configured to allow a group of users to sudo a particular command as a particular user.

    For example, you could create a group scriptUsers and a user scriptRun. Then, configure sudo to let any user in scriptUsers become scriptRun ONLY to run your script.

提交回复
热议问题