Results 1 to 8 of 8

Thread: sudo & root pass in one line!?

  1. #1
    Join Date
    Jun 2013
    Beans
    4

    Question sudo & root pass in one line!?

    Hi;
    I need a command in terminal to use sudo and the root password in a single line!
    In general we enter sudo and then terminal prompt us to insert pass but i wanna to insert sudo and pass in one step!
    Is it possible?

    J.S
    Be free...

  2. #2
    Join Date
    Sep 2006
    Beans
    7,561
    Distro
    Lubuntu Development Release

    Re: sudo & root pass in one line!?

    You can set specific programs to not need passwords in sudo, but you have to be careful in setting it up.

    Here is one example:

    Code:
    %adm ALL=(ALL) NOPASSWD: /sbin/ifconfig eth0 *
    It allows anyone in the group adm to adjust the interface eth0.

  3. #3
    Join Date
    Feb 2012
    Location
    el_GR
    Beans
    Hidden!
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: sudo & root pass in one line!?

    For one time you can do
    Code:
    echo "password here" | sudo -S apt-get update && history -c
    The apt-get update command is an example here, you can replace it with yours.

    The passwd file contains your password and because of it is dangerous to have your password in a text file, the last command rm passwd will remove this text file at the end.

    The history -c will remove all the bash shell's history , where your password is exposed.

    Regards
    NikTh
    Last edited by NikTh; June 18th, 2013 at 04:38 PM. Reason: edited the command due to Lars Nooden's comment

  4. #4
    Join Date
    Jun 2013
    Beans
    4

    Re: sudo & root pass in one line!?

    thx NikTh for your help...

    have good times
    Last edited by shirani; June 18th, 2013 at 04:30 PM. Reason: don't see new post

  5. #5
    Join Date
    Sep 2006
    Beans
    7,561
    Distro
    Lubuntu Development Release

    Re: sudo & root pass in one line!?

    That could be boiled down even shorter, skipping the redirect to a file and just piping the echo into sudo. However, either way you end up with the password unencryped in the shell's history which is a very big risk. If you do either way, the history should be cleared immediately, history -c but if you are using another shell than bash, the method might be different. I'd advise against anything that puts the password in cleartext.

  6. #6
    Join Date
    Feb 2012
    Location
    el_GR
    Beans
    Hidden!
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: sudo & root pass in one line!?

    Quote Originally Posted by Lars Noodén View Post
    with the password unencryped in the shell's history....
    This is absolutely right !!! I edited my command. !!

    Thanks

  7. #7
    Join Date
    Jun 2013
    Beans
    4

    Re: sudo & root pass in one line!?

    Thanks Lars and NikTh...

    Have good times....

  8. #8
    Join Date
    Feb 2012
    Location
    el_GR
    Beans
    Hidden!
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: sudo & root pass in one line!?

    Please mark the thread as solved. See my signature for a How To.

    Regards
    NikTh

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
  •