This is just some notes for myself that may be useful for other people.
Scenario: As a server administrator I want to keep the backups secure so only myself can restore them.
OSX hostname: earth.local
Ubuntu Server hostname: mars.local
GPG Installation
1 2 3 4 5 |
#OSX $ brew install gpg #Ubuntu $ sudo apt install gpgv2 |
Creating keys
1 2 |
earth$ gpg --gen-key earth$ gpg --list-keys |
Encrypt a file test
1 |
earth$ gpg -e -u albertsola -r albertsola mysql.sql |
Decrypt a file test
1 |
earth$ gpg -d mysql.sql.gpg > mysql.sql |
Exporting public key
1 2 |
earth$ gpg --output pub_albertsola.gpg --export albertsola #binary earth$ gpg --armor --export albertsola > pub_albertsola.asc #text |
Importing a public keys on the server
1 |
mars$ gpg --import pub_albertsola.asc |
Encrypting the backup
1 2 |
mars$ gpg -e -u backups@domain.com -r albertsola@domain.com mysql.sql mars$ rm mysql.sql |
Downloading and decrypting the backup
Copy the file to earth:
1 2 3 |
earth$ scp albertsola@mars:~/backups/mysql.sql.gpg . earth$ gpg -d mysql.sql.gpg > mysql.sql earth$ rm mysql.sql.pgp |