Encryption :
[root@unixfoo-lin23 ~]# tar cvzf – passwd_info.txt | openssl des3 -salt -k secretkey | dd of=encrypted_passwd_info
passwd_info.txt
20+1 records in
20+1 records out
[root@unixfoo-lin23 ~]# file encrypted_passwd_info
encrypted_passwd_info: data
[root@unixfoo-lin23 ~]# tar tvzf encrypted_passwd_info
gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error exit delayed from previous errors
[root@unixfoo-lin23 ~]#
Decryption :
[root@unixfoo-lin12 ~]# dd if=encrypted_passwd_info |openssl des3 -d -k secretkey |tar xvzf –
20+1 records in
20+1 records out
passwd_info.txt
[root@unixfoo-lin12 ~]# cat passwd_info.txt | head -1
UNIX User UNIX Password
[root@unixfoo-lin12 ~]#
This method can also be used to gzip and encrypt any file or directory.