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

Consider a file with user-read-only permissions, for example ...

-r--------+ admin secrets.txt

How can such a file be put under revision control, so that its contents remain secret, even from the revision control administrator?

share|improve this question

2 Answers 2

Use GPG to encrypt the file before commiting to your repo.

Yes, it's cumbersome (you won't be able to diff/merge/etc. without decrypting first) but I can't conceive of any other way to skin this cat.

share|improve this answer

Store the secrets in a separate file (not under version control), and insert the secret content into the other file with a script or Puppet-like tool.

Working from this other answer, a simple example could be: (stored in version control):

# Usage: /path/to/samba/binary/net pdc-hostname
HOSTNAME=`facter hostname`-`facter operatingsystem`
PASSWORD=<%= scope.function_generate("/etc/puppet/auth/getpwd", "ad", "netjoin") %>
${NET} rpc user delete ${HOSTNAME}\$ -U netjoin%${PASSWORD} -S ${SERVER}
${NET} rpc join -U netjoin%${PASSWORD} -S ${SERVER}
/bin/rm -f $0

/etc/puppet/auth/getpwd (can also be stored in version control):

# /etc/puppet/auth/getpwd
if [ "$#" -ne 2 ]; then
    echo "Usage: $0 <db> <user>"
    exit 1
if [ ! -x /usr/bin/pwgen ]; then
    echo "missing pwgen!" >&2
    exit 1
workdir=`dirname $0`
[ ! -r $workfile ] && exit 2
# get password from storage
pwd=`egrep "^${get_name}:" ${workfile} | cut -d: -f2-`
if [ "$pwd" = "" ]; then
    # generate new password & store it
    len=$((60 + $RANDOM % 9 ))
    pwd=$(/usr/bin/pwgen -s $len 1)
    echo "${get_name}:${pwd}" >> $workfile
# echo password (without new line)
echo -n "$pwd"

/etc/puppet/auth/passwd_ad (absolutely not in version control):

share|improve this answer

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.