I am using openssl to encrypt my backups before send it to an ftp server where I store them.
At first, when I tried to decrypt the files I was getting this error:
openssl rsautl -decrypt -inkey ../key.server.pem -in enc.key.txt -out key.txt RSA operation error 139759177856680:error:0407106B:rsa routines:RSA_padding_check_PKCS1_type_2:block type is not 02:rsa_pk1.c:190: 139759177856680:error:04065072:rsa routines:RSA_EAY_PRIVATE_DECRYPT:padding check failed:rsa_eay.c:616:
I am following this steps to encrypt.
I thought the problem was with the encryption, but checking the md5sum of the file show me that the file on the server had changed with the one I downloaded from the ftp server. A example:
I have a file called enc.key.txt that contains a passphrase to decrypt the backup:
$ hexdump enc.key.txt //... //... 0000100 16e3 c2e3 cecd 2afe eb8c 9617 8d58 *0dd0* //...
And the hexdump of enc.key.txt once downloaded to my computer differ by one value, in this line:
//... 0000100 16e3 c2e3 cecd 2afe eb8c 9617 8d58 *0ad0* //...
I've edited the value with an hex editor and then I was able to decrypt the file, but I don't know why is the file being modified.
I am sending the backups to the ftp server with ncftp like this:
### Dump backup using FTP ### #Start FTP backup using ncftp ncftp -u"$FTPU" -p"$FTPP" $FTPS<<EOF mkdir $FTPD mkdir $FTPD/$NOW cd $FTPD/$NOW put enc.key.txt lcd $BACKUP mput * quit EOF
Could you help me? Thanks in advance