In some situations, you might want to run two instances of the Bareos File Daemon (bareos-fd) on a single client, one with data encryption enabled and one without. For example, maybe you want to encrypt only backups to off-site storage, and keep local backups unencrypted for better storage deduplication and lower risk due to lost encryption keys.
One way to do this is to run the encryption-enabled bareos-fd on a non-standard port 9104.
Procedure
Keys
-
Set up a directory on the Bareos Director (or somewhere else secure) to contain the master and client keypairs.
mkdir /etc/bareos/pki chmod 750 /etc/bareos/pki chown root:bareos /etc/bareos/pki -
Generate the master keypair.
openssl genrsa -out master.key 2048 openssl req -new -key master.key -x509 -out master-pub.cert -
Generate a client keypair and prepare a PEM file. req_defaults.conf has some optional OpenSSL defaults.
openssl genrsa -out spot.example.org-enc-fd.key 2048 openssl req -config req_defaults.conf -key spot.example.org-enc-fd.key -x509 -out spot.onnela.feep.org-enc-fd.cert cat spot.example.org-enc-fd.key spot.onnela.feep.org-enc-fd.cert > spot.onnela.feep.org-enc-fd.pem chmod 600 spot.example.org-enc-fd.pem -
Copy master-pub.cert and the client PEM file to
/etc/bareos-enc/pkion the client.
Client
Systemd Service
Assuming there is also an unencrypted bareos-fd running on this client, we’ll create a second configuration directory tree and systemd service. Otherwise, this can all be configured in the standard location.
-
Install the bareos-filedaemon package.
-
Make a copy of the standard configuration directory and its contents.
cp -av /etc/bareos /etc/bareos-enc -
Create a directory for the keys.
mkdir /etc/bareos-enc/pki chmod 750 /etc/bareos-enc/pki chown root:bareos /etc/bareos-enc/pki -
Copy master-pub.cert and the client PEM file into
/etc/bareos-enc/pki -
Make a copy of the default systemd unit file.
-
Debian
cp /usr/lib/systemd/system/bareos-filedaemon.service /etc/systemd/system/bareos-filedaemon-enc.service -
Fedora
cp /usr/lib/systemd/system/bareos-fd.service /etc/systemd/system/bareos-fd-enc.service
-
-
Edit the copied unit file, adding a parameter pointing to the new configuration directory.
ExecStart=/usr/sbin/bareos-fd -c /etc/bareos-enc -f -
Also update
Aliasby adding-encto the service name. -
Enable the new service.
systemctl enable bareos-filedaemon-enc
Bareos Configuration
-
Enable encryption and alternate port number in
/etc/bareos-enc/bareos-fd.d/client/myself.confClient { Name = spot.example.org-fd FD Port = 9104 PKI Signatures = yes PKI Encryption = yes PKI Keypair = "/etc/bareos-enc/pki/spot.example.org-enc-fd.pem" PKI Master Key = "/etc/bareos-enc/pki/master-pub.cert" PKI Cipher = aes256 } -
Enable connection from the Bareos Director to the File Daemon on the alternate port.
-
Debian
ufw allow from 172.16.0.156 proto tcp to any port 9104 -
Fedora
firewall-cmd --zone=public --add-rich-rule='rule family=ipv4 source address=172.16.0.156/32 port port=9104 protocol=tcp accept' firewall-cmd --zone=public --add-rich-rule='rule family=ipv4 source address=172.16.0.156/32 port port=9104 protocol=tcp accept' --permanent
-
-
Add client using the Bareos console.
configure add client name=spot.example.org-enc-fd address=172.16.0.125 port=9104 password=somepassword -
Add the MD5 hash to the client’s
/etc/bareos-enc/bareos-fd.d/director/bareos-dir.conf. -
Start the File Daemon.
systemctl start bareos-filedaemon-enc -
Test connection from the Director, and configure a backup job as usual.