Results 1 to 5 of 5

Thread: Running program as different user (without password)

  1. #1
    Join Date
    Mar 2008
    Beans
    19

    Running program as different user (without password)

    Hi,

    I'm trying to run a program as a different user (but not root) without being prompted for a password. I read up on sudoers and thought the following addition to /etc/sudoers would do the trick (where my user is vt and I want to run /usr/bin/top as user rawvb):
    Code:
    vt ALL=(rawvb) NOPASSWD: /usr/bin/top
    However when I run the following I still get prompted for a password:
    Code:
    sudo -u rawvb /usr/bin/top
    I've searched these forums but couldn't find any threads detailing this (they all seem to be about running certain commands as root).


    Regards,
    VT

    *** Edit ***
    I found this thread which doesn't have a solution however.
    Last edited by vkov_tinsky; September 18th, 2008 at 05:36 PM. Reason: Found a related thread (although that still does not help)

  2. #2
    Join Date
    Dec 2006
    Location
    Chicago
    Beans
    3,839

    Re: Running program as different user (without password)

    Quote Originally Posted by vkov_tinsky View Post
    Hi,

    I'm trying to run a program as a different user (but not root) without being prompted for a password. I read up on sudoers and thought the following addition to /etc/sudoers would do the trick (where my user is vt and I want to run /usr/bin/top as user rawvb):
    Code:
    vt ALL=(rawvb) NOPASSWD: /usr/bin/top
    However when I run the following I still get prompted for a password:
    Code:
    sudo -u rawvb /usr/bin/top
    I've searched these forums but couldn't find any threads detailing this (they all seem to be about running certain commands as root).


    Regards,
    VT

    *** Edit ***
    I found this thread which doesn't have a solution however.
    That's odd, becuase this line works correctly for me
    Code:
    cdenley ALL=(rawvb) NOPASSWD: /usr/bin/whoami
    Code:
    cdenley@ubuntu:~$ sudo -K
    cdenley@ubuntu:~$ sudo -u rawvb whoami
    rawvb

  3. #3
    Join Date
    Mar 2008
    Beans
    19

    Re: Running program as different user (without password)

    What can I say... I'm running Xubuntu 8.04 and all I have in /etc/sudoers is:

    Code:
    # /etc/sudoers
    #
    # This file MUST be edited with the 'visudo' command as root.
    #
    # See the man page for details on how to write a sudoers file.
    #
    
    Defaults	env_reset
    
    # Uncomment to allow members of group sudo to not need a password
    # %sudo ALL=NOPASSWD: ALL
    
    # Host alias specification
    
    # User alias specification
    
    # Cmnd alias specification
    
    # User privilege specification
    root	ALL=(ALL) ALL
    vt	ALL=(rawvb) NOPASSWD: /usr/bin/top
    
    # Members of the admin group may gain root privileges
    %admin ALL=(ALL) ALL
    And obviously when I run sudo -u rawvb top I get the password prompt cancelling which adds to /var/log/auth.log:
    Code:
    ogimogi sudo:       vt : pam_authenticate: Conversation error ; TTY=pts/0 ; PWD=/home/vt ; USER=rawvb ; COMMAND=/usr/bin/top
    The only possibly related thing I can think off is that I installed the libpam-gnome-keyring package (so automatically retrieve the key for my wireless connection upon login). Or do I maybe have to set something in System->Authorizations?

    Any suggestions would be appreciated.

    Regards,
    VT

  4. #4
    Join Date
    Dec 2006
    Location
    Chicago
    Beans
    3,839

    Re: Running program as different user (without password)

    I think you might have to add the NOPASSWD line at the end.

  5. #5
    Join Date
    Mar 2008
    Beans
    19

    Re: Running program as different user (without password)

    Quote Originally Posted by cdenley View Post
    I think you might have to add the NOPASSWD line at the end.
    D'oh! That's exactly what it was, thanks

    Regards,
    VT

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
  •