Bacula permits file data encryption and signing within the File Daemon (or Client) prior to sending data to the Storage Daemon. Upon restoration, file signatures are validated and any mismatches are reported. At no time does the Director or the Storage Daemon have access to unencrypted file contents.
It is very important to specify what this implementation does NOT do:
Encryption and signing are implemented using RSA private keys coupled with self-signed X.509 public certificates. This is also sometimes known as Public-Key Infrastructure (PKI).
Each File Daemon should be given its own unique private/public key pair. In addition to this key pair, any number of “Master Keys” may be specified - these are key pairs that may be used to decrypt any backups should the File Daemon key be lost. Only the Master Key's public certificate should be made available to the File Daemon. Under no circumstances should the Master Private Key be shared or stored on the Client machine.
The Master Keys should be backed up to a secure location, such as a CD placed in a in a fire-proof safe or bank safety deposit box. The Master Keys should never be kept on the same machine as the Storage Daemon or Director if you are worried about an unauthorized party compromising either machine and accessing your encrypted backups.
While less critical than the Master Keys, File Daemon Keys are also a prime candidate for off-site backups; burn the key pair to a CD and send the CD home with the owner of the machine.
NOTE!!! If you lose your encryption keys, backups will be unrecoverable. ALWAYS store a copy of your master keys in a secure, off-site location.
The basic algorithm used for each backup session (Job) is:
To build Bacula with encryption support, you will need the OpenSSL libraries and headers installed. When configuring Bacula, use:
./configure --with-openssl ...
Please note, the Bacula Enterprise binaries are all built with encryption enabled.
End-user configuration settings for the algorithms are not currently exposed - only the algorithms listed above are used. However, the data written to Volume supports arbitrary symmetric, asymmetric, and digest algorithms for future extensibility, and the back-end implementation currently supports:
The various algorithms are exposed via an entirely re-usable, OpenSSL-agnostic API (ie, it is possible to drop in a new encryption backend). The Volume format is DER-encoded ASN.1, modeled after the Cryptographic Message Syntax from RFC 3852. Unfortunately, using CMS directly was not possible, as at the time of coding a free software streaming DER decoder/encoder was not available.
VSS: no Encryption: no/yes <=== Accurate: no ...
Generate a Master Key Pair (once) with:
openssl genrsa -out master.key 2048 openssl req -new -key master.key -x509 -out master.cert
Save these files (master.key and master.cert) as you will need them to create File Daemon keys or in case you loose the File Daemon keys.
Generate a File Daemon Key Pair for each FD:
openssl genrsa -out fd-example.key 2048 openssl req -new -key fd-example.key -x509 -out fd-example.cert cat fd-example.key fd-example.cert >fd-example.pem
When configuring the File Daemon (see section (here)), you will need the keys you just generated here, so you will need to transmit them to the machine where the FD is installed.
Note, there seems to be a lot of confusion around the file extensions given to these keys. For example, a .pem file can contain all the following: private keys (RSA and DSA), public keys (RSA and DSA) and (X.509) certificates. It is the default format for OpenSSL. It stores data Base64 encoded DER format, surrounded by ASCII headers, so is suitable for text mode transfers between systems. A .pem file may contain any number of keys either public or private. We use it in cases where there is both a public and a private key.
Typically, above we have used the .cert extension to refer to X.509 certificate encoding that contains only a single public key.
When configuring the FD, use the keys generated above in a FD configuration file that will look something like the following:
bacula-fd.conf
FileDaemon { Name = example-fd FDport = 9102 # where we listen for the director WorkingDirectory = /opt/bacula/working Pid Directory = /var/run Maximum Concurrent Jobs = 20 PKI Signatures = Yes # Enable Data Signing PKI Encryption = Yes # Enable Data Encryption PKI Keypair = "/opt/bacula/etc/fd-example.pem" # Public and Private Keys PKI Master Key = "/opt/bacula/etc/master.cert" # ONLY the Public Key }
You must restart your File Daemon after making this change to the bacula-fd.conf file.
First create a keypair with:
cat master.key master.cert >master.pem
Then modify your File Daemons configuration file to use the master keypair:
FileDaemon { Name = example-fd FDport = 9102 # where we listen for the director WorkingDirectory = /opt/bacula/working Pid Directory = /var/run Maximum Concurrent Jobs = 20 PKI Signatures = Yes # Enable Data Signing PKI Encryption = Yes # Enable Data Encryption PKI Keypair = "/opt/bacula/etc/master.pem" # Master Public and Private Keys }
Restart your File Daemon and you should be able to recover your lost files.