Results 1 to 7 of 7

Thread: Put sudo password into bash file

  1. #1
    Join Date
    May 2013
    Beans
    19

    Put sudo password into bash file

    Hi there

    I would like to run below command into `.sh` file :
    Code:
    #! /bin/sh -e
    sleep 20
    sudo /opt/lampp/lampp start
    123456  #it's sudo password
    exit 0
    It's doesn't start `lampp`.
    I think, i have put sudo password in wrong place.

    Thank You
    Last edited by kamrava; June 17th, 2013 at 12:15 PM.

  2. #2
    Join Date
    Apr 2008
    Location
    LOCATION=/dev/random
    Beans
    5,767
    Distro
    Ubuntu Development Release

    Re: Put sudo password into bash file

    Is this script going to be run every time the system boots?

    Also do you have a good reason to be using lampp instead of the standard lamp stack that's in the Ubuntu repositories?
    Cheesemill

  3. #3
    Join Date
    May 2010
    Location
    uk
    Beans
    9,324
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: Put sudo password into bash file

    Hi

    Please, please, please don't put your password in a script.

    It's such a huge security risk and, from looking at your script, i suspect there are other ways to achive what you want.

    Kind regards
    If you believe everything you read, you better not read. ~ Japanese Proverb

    If you don't read the newspaper, you're uninformed. If you read the newspaper, you're mis-informed. - Mark Twain

    Thinking about becoming an Ubuntu Member?

  4. #4
    Join Date
    May 2013
    Beans
    19

    Re: Put sudo password into bash file

    Quote Originally Posted by Cheesemill View Post
    Is this script going to be run every time the system boots?
    Yes.

    Quote Originally Posted by Cheesemill View Post
    Also do you have a good reason to be using lampp instead of the standard lamp stack that's in the Ubuntu repositories?
    Lampp is not in Ubuntu repositories by default.

    Quote Originally Posted by matt_symes View Post
    It's such a huge security risk and, from looking at your script, i suspect there are other ways to achive what you want.
    What i must to do?

    Regards

  5. #5
    Join Date
    Apr 2008
    Location
    LOCATION=/dev/random
    Beans
    5,767
    Distro
    Ubuntu Development Release

    Re: Put sudo password into bash file

    If you want a command to be run every time the system boots then you can add it to the /etc/rc.local file. All commands in this file are run with root privileges.
    Lampp is not in Ubuntu repositories by default.
    No it isn't, but the industry standard lamp stack is, you can install it by doing...
    Code:
    sudo apt-get install lamp-server^
    Installing the proper version from the repositories instead of the version that you have installed will mean that all of the packages will get updated along with the rest of your system.
    Also when you install the version in the repositories it automatically sets up the services to be started when the machine boots, so you don't need to fudge together a startup script like you are trying to do.
    Cheesemill

  6. #6
    Join Date
    May 2010
    Location
    uk
    Beans
    9,324
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: Put sudo password into bash file

    Hi

    What i must to do?
    Follow Cheesemill's sage advice.

    I run an apache server on my servers and on my notebook.

    One thing you should look into after installing it is how how harden it and we have the security sub forum with some good advice on how to do this.

    Kind regards
    If you believe everything you read, you better not read. ~ Japanese Proverb

    If you don't read the newspaper, you're uninformed. If you read the newspaper, you're mis-informed. - Mark Twain

    Thinking about becoming an Ubuntu Member?

  7. #7
    Join Date
    Aug 2007
    Location
    From the land down under
    Beans
    1,243
    Distro
    Ubuntu Development Release

    Re: Put sudo password into bash file

    Just a note that you don't usually put sudo in a script, you make the script run using sudo. Which is usually via cron (running as root if necessary).
    // Blog

Tags for this Thread

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
  •