How to Hide Credentials from Percona Monitoring and Management Client Commands

Hide Credentials from Percona Monitoring and Management Client CommandsIn this short blog post, we are going to review how to avoid using credentials in the Percona Monitoring and Management (PMM) client command line when adding new exporters. We will use an example with the MySQL exporter, but it is extensible to others (PostgreSQL, MongoDB, etc.).

In the online documentation we can see the basic steps for adding a new MySQL exporter:

  1.  Configure the PMM client 
    1. pmm-admin config ...
  2. Add the MySQL exporter
    1. pmm-admin add mysql --username=pmm --password=pass

The issue with this approach is that the user and password are there in plain sight for anyone to see, be it through the shell history or via commands like ps aux.

The PMM client uses kingpin to parse the arguments given, so we can use its feature for reading them from a file to do it in a more secure way. We just need to create the files with the arguments we want to hide from the commands, like:

Note that the above commands were used for simplicity in showing how they can be created. If you are worried about leaving traces in the shell command history use vim (or your editor of choice) to actually create the files and their contents.

We can use these files in the following way, instead:

We can still use other arguments in the command directly. For example, for the MySQL command:

PMM clients will not store database credentials within themselves, but will instead request this data from the PMM server. After the exporters are added and running, remove the pmm-admin conf files.

Using Shell Variables

Another way of achieving this is to use “hidden” variables, like:

You can then even wipe the variable out if you want:

Complete the 2021 Percona Open Source Data Management Software Survey

Have Your Say!

Share this post

Leave a Reply