Results 1 to 3 of 3

Thread: How to run python script with root but without password

Hybrid View

  1. #1
    Join Date
    May 2012
    Beans
    32

    How to run python script with root but without password

    Hi there,

    I'm fairly new to linux permissions. I have a Python script that does things such as run shell scripts, dd, ntfsclone, ntfsresize. Many of which require me to sudo and enter a password. The requirements are that the script should run on boot and not require a password of the user.

    I have added various things to sudoers:

    Code:
    username ALL=(ALL) ALL
    username ALL=NOPASSWD: /path/to/my/script.py
    username ALL=NOPASSWD: /usr/bin/python,/bin/dd,/bin/sh
    none of these seem to work. When I run
    Code:
    python myscript.py
    it gets to the point in the script where it is running

    Code:
    os.system("./shellscript.sh")
    and asks for a password.

    Thanks for any help!

    -Jolladay

  2. #2
    Join Date
    May 2012
    Beans
    32

    Re: How to run python script with root but without password

    Does anyone know how to do this?

    -Jolladay

  3. #3
    Join Date
    Jul 2011
    Beans
    19

    Re: How to run python script with root but without password

    try adding sudo at the beginning
    Code:
    sudo python myscript.py
    also make sure to add it after %admin as noted here
    https://help.ubuntu.com/community/Sudoers
    Last edited by boshkash1151; June 1st, 2012 at 06:08 PM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •