Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We have a few shell scripts for backup/database dump purpose which have username/password info in them. Is there any way do this other than SHC which appears to be having some issues.

share|improve this question

Encryption will never help for this on its own, as every user who has to run it also needs to be able to decrypt it.

If you need non-admin users to run a backup script, you should use something like sudo to give them the rights to run that script but not the rights to read the passwords (i.e. make sure the permissions are set such that the user can't read them).

share|improve this answer
+½ for pointing out the pitfall, though the solution requires the script to be non-exploitable which usually no software is ^^ – Oskar Duveborn Sep 17 '10 at 8:15

I don't know any encryption solution.

But you might consider another approach by filling your login information into a file with appropriate access rights. (MySQL = .my.cnf, PostgresSQL = .pgpass etc).

That way you can avoid encrypting your shell scripts which doesn't sound secure to me anyway.

share|improve this answer

Do normal users need to be able to run these scripts? Presumably you could have a backup user and set the permissions on the script to 700. If you really needed to let other people to run the script you could use sudo. You have very little chance of hiding the passwords from the root user.

share|improve this answer
up vote 0 down vote accepted

Found a good solution using GPG

share|improve this answer
How is that secure? Where and how do you store the key? – Oskar Duveborn Sep 17 '10 at 8:13
I read that post and they do point out the weakness. – Allen Aug 22 '11 at 0:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.