I have bunch of log files which I am trying to encrypt with public/private key using openssl and save to my NAS but it is failing.
My log files are in the following path :
/var/SYSLOGS/hosts/archive
My public key and private key are in /etc/log-enc/
[root@NAG01 log-enc]# ls -l
total 8
-rw-r--r-- 1 root root 891 Jul 11 15:58 syslog_privalye_key.pem
-rw-r--r-- 1 root root 272 Jul 11 15:59 syslog_public_key.pem
Now I am trying to execute following command If I am executing the same command one by one, then there is no issue.
for file in `find /var/SYSLOGS/hosts/archive/`
do
FILE_BASE=$(basename $file)
echo "$file=>/NFS/Nag01/syslogs/hosts/$FILE_BASE.enc"
openssl rsautl -encrypt -inkey /etc/log-enc/syslog_public_key.pem -pubin -in $file -out /NFS/Nag01/syslogs/hosts/$FILE_BASE.enc
done
Here are the error logs
RSA operation error
140628568049480:error:0406D06E:rsa routines:RSA_padding_add_PKCS1_type_2:data too large for key size:rsa_pk1.c:151:
/var/SYSLOGS/hosts/archive/192.168.33.5.log-20160131.gz=>/NFS/Nag01/syslogs/hosts/192.168.33.5.log-20160131.gz.enc
RSA operation error
140123978278728:error:0406D06E:rsa routines:RSA_padding_add_PKCS1_type_2:data too large for key size:rsa_pk1.c:151:
/var/SYSLOGS/hosts/archive/app02.log-20160306.gz=>/NFS/Nag01/syslogs/hosts/app02.log-20160306.gz.enc
/var/SYSLOGS/hosts/archive/192.168.34.8.log-20160227.gz=>/NFS/Nag01/syslogs/hosts/192.168.34.8.log-20160227.gz.enc
RSA operation error
139777258493768:error:0406D06E:rsa routines:RSA_padding_add_PKCS1_type_2:data too large for key size:rsa_pk1.c:151:
/var/SYSLOGS/hosts/archive/192.168.31.3.log-20160511.gz=>/NFS/Nag01/syslogs/hosts/192.168.31.3.log-20160511.gz.enc
Here are the raw files.
[root@NAG01 log-enc]# ls -l /var/SYSLOGS/hosts/archive/192.168.33.5.log-20160131.gz
-rw-------. 1 root root 3569 Jan 31 04:16 /var/SYSLOGS/hosts/archive/192.168.33.5.log-20160131.gz
[root@NAG01 log-enc]# ls -l /var/SYSLOGS/hosts/archive/192.168.34.8.log-20160227.gz
-rw-------. 1 root root 2142 Feb 27 03:11 /var/SYSLOGS/hosts/archive/192.168.34.8.log-20160227.gz
openssl rsautl -encrypt -inkey /etc/log-enc/syslog_privalye_key.pem -in $file -out /NFS/Nag01/syslogs/hosts/$FILE_BASE.enc