Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6891053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:21:38+00:00 2026-05-27T06:21:38+00:00

I wrote a shell script to hook into a password protected database. A couple

  • 0

I wrote a shell script to hook into a password protected database. A couple of others want to use the same shell script to share the database access, but I don’t want to expose the password that is being used. Is there a way to lock the script so that no one can read it and only execute it? It’d also be ideal for them to enter their sudo password to run the script

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:21:38+00:00Added an answer on May 27, 2026 at 6:21 am

    Is there a way to lock the script so that no one can read it and only
    execute it? It’d also be ideal for them to enter their sudo password
    to run the script

    Sure. Let’s say the script containing the credentials is /usr/local/bin/myscript. Make this file owned by a privileged user. Let’s say we have a user named “credentials”:

    # chown credentials /usr/local/bin/myscript
    # chmod 700 /usr/local/bin/myscript
    

    Now only the credentials user can read and execute this script.

    Create another script /usr/local/bin/mywrapper that looks like this:

    #!/bin/sh
    exec sudo -u credentials /usr/local/bin/myscript
    

    And create the appropriate /etc/sudoers entry:

    auser   ALL=(credentials) /usr/local/bin/myscript
    

    So now, user auser runs “mywrapper”. This in turn uses sudo to call the real script, which will prompt auser for their password.

    I think this does everything you want. We use a mechanism very much like this at my office to protect credentials (in our case, ssh private keys).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use the system command in a bash shell script. Being more
This is a crude korn shell script that someone else wrote. I don't know
I wrote a bash shell script to rename the file, #!/bin/bash #renaming the files
I wrote a shell script like this: #! /bin/sh ... ls | grep android
I am new to linux and its shell programming. I wrote a shell script
I while back I wrote a shell script that automatically runs a python script
I wrote a shell script that lets me grep through a directory tree and
I wrote the following shell script: #!/bin/bash MAIL=/usr/mail/${LOGNAME:?} . /installations/etl_scripts/etl_job.properties JOB_LOG_FILE_PATH=$JOB_LOG_FILE_PATH export JOB_LOG_FILE_PATH JOB_LOG_FILE_NAME=$JOB_LOG_FILE_NAME
I wrote a simple PHP shell script which parses files and outputs certain element.
I wrote to functions in shell script to read and write variable settings from/to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.