I previously asked (and answered) a question on how to preseed debconf on Ubuntu: How do you preseed debconf from a previously installed package?

I found that just appending to the config.dat file worked. However appending to the passwords.dat file didn't work because it seemed to create a blank (or otherwise unusable password). The passwords.dat preseed looks like this:

Name: couchdb/adminpass
Template: couchdb/adminpass
Owners: couchdb
Flags: seen

Name: couchdb/adminpass_again
Template: couchdb/adminpass_again
Owners: couchdb
Flags: seen

It didn't matter whether I added anything in the value field - Couch crashes anyway when trying to enter the admin password.

How do I preconfigure password information in debconf?


Not sure if you found a solution yet, but there appears to be NO great or intuitive way to do this. There are a few solutions, though....

First, you could try debconf-set-selections (man page (not all that useful)) from the debconf package. This seems to have been intended to mirror configurations from one machine to another. It accepts either a file with line-by-line commands (presumably created with debconf-get-selections > my-conf.debconf), or STDIN input (presumably piped from debconf-get-selections on another machine). You can also fire it up via sudo debconf-set-selections and deliver commands (using ctrl-d to quit), or you can pipe commands in via echo.

Input syntax for this appears to be something like

[package-name] [package-name]/[question-name] [type] [value]

For example, to configure the openssh server to deny root passwords by default whenever anyone installs sshd via debconf, you could run

echo "openssh-server openssh-server/permit-root-login boolean false" | sudo debconf-set-selections

Alternatively, you could use the debconf-communicate program, which is similar to debconf-set-selections, except that it allows a more interactive session using commands found here. You might use this like so:

$ sudo debconf-communicate
$ GET openssh-server/permit-root-login
$ 0 false
$ SET openssh-server/permit-root-login true
$ 0 value set
$ GET openssh-server/permit-root-login
$ 0 true
$ FSET openssh-server/permit-root-login seen true
$ 0 true
$ FGET openssh-server/permit-root-login seen       
$ 0 true
$ SET openssh-server/permit-root-login false
$ 0 value set

This feels like ripe territory for someone to swoop in and write a better debconf front-end....

Obviously if you're scripting this, your best bet would be the debconf-set-selections route.

As a final note, unfortunately, finding out what options are available for a package is even harder. Your options include:

  1. Downloading the package via sudo apt-get download [package-name] [dir], unpacking it via dpkg-deb -R [filename] [unpacked-dirname], and inspecting the [unpacked-dirname]/DEBIAN/templates file; or
  2. Using sudo debconf-show [package-name] to view config questions for already installed packages. (Note that packages DO NOT have to register questions under their own name.)

Anyway, hope that helps...

  • Ooo, also, take a look at the debconf manpage, and in particular the "ENVIRONMENT" section down at the bottom. It looks like, as a hack (yes, another one), you could use dpkg-preconfigure to get all the configuration variables for a package into the database, then dump the database to file using debconf-get-selections | grep [package-name] > my-conf.debconf then import the file using the debconf-set-selections my-conf.debconf..... – kael Feb 7 '18 at 22:04
  • Yea using debconf-set-selections was the easiest. But I found the documentation to be absolutely terrible which is why I couldn't figure out how at first. – Zach Smith Feb 8 '18 at 7:40

As mentioned in the accepted answer, debconf-set-selections was the way to go on this.

Basically you need to install package manually first and then look through the debconf database to see what entries are created (I can't remember offhand how I did this, sorry).

Then you can create a .sh script that will pre-seed those entries for you. This is code that shows how to pre-seed the CouchDB 2.0 package installer:

HOST = aaa
USER = bbb

debconf-set-selections <<< 'couchdb couchdb/bindaddress string';
debconf-set-selections <<< 'couchdb couchdb/cookie string monster';
debconf-set-selections <<< 'couchdb couchdb/mode string clustered';
debconf-set-selections <<< 'couchdb couchdb/nodename string couchdb@#{HOST}';
debconf-set-selections <<< 'couchdb couchdb/adminpass password #{COUCH_PSWD}';
debconf-set-selections <<< 'couchdb couchdb/adminpass_again password #{COUCH_PSWD}';
  • Note: If you don't want to install the package, you can do the whole download-unpack-inspect thing that I mentioned in #1 of the last part of my answer. All values set by the package will be found in config, and all values used by the package will be found in postinst (packages can use other packages' values, or even create shared values). – kael Feb 8 '18 at 17:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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