Get Social

How to encrypt a backup and upload it on ftp or sftp?

If you need to upload backup to a third-party ftp-server (archive, just a file), however, you need to ensure that important information does not fall into the wrong hands, before uploading, encrypt it with a password and then upload it.

We encrypt the file with the openssl command

openssl aes-256-cbc -salt -in FILE -out FILE.aes -k PASSWORD
(openssl there are in most Linux distributions, and you can also install it in windows and mac os)
To request a password, you need to remove the “-k PASSWORD”.
You can decrypt with the command
openssl aes-256-cbc -d -salt -in FILE.aes -out FILE -k PASSWORD


How to upload to ftp (using curl best)

curl -s -T FILE -u USER:PASSWORD ftp://ftpserverhostname


How to upload to sftp

rsync -avz -e ssh USER@PASSWORD:/remote/directory/ /current/directory/file


How to upload to sftp with curl

short answer – use rsync over ssh and do not suffer 🙂