Linux Programmer | RHCE | RHCSA

Search This Blog

Create Password Protected .tar file in linux.

When you have important sensitive data, then its crucial to have an extra layer of security to your files and directories, specially when you need to transmit the data with others over a network.
use "gpg" for creating password protected .tar
1. tar Creation
tar czvpf - /path/tp/directory | gpg --symmetric --cipher-algo aes256 -o myarchive.tar.gz.gpg
this will ask for the password
enter password:
repeat password:
Once you have entred the password then it will start the process.

Extract .tar file.
gpg -d  myarchive.tar.gz.gpg | tar xzvf -

it will ask for the password. once you entered correct password it will start extracting process.

Unlock it .tar with key file 
1. tar czvpf - /path/tp/directory | gpg --symmetric --cipher-algo aes256 -o myarchive.tar.gz.gpg
enter paraphrase key
store this paraphrase key into some file . for e.g. /$HOME/passkey.pem
2. Extract tar with key file
gpg -d --passphrase `cat /path/to/keyfile/passkey.pem` myarchive.tar.gz.gpg | tar xzvf -

No comments:

Post a Comment

SSH not working with password after upgrade ubuntu 22.04 or above

In recent upgrade of ubuntu 22.04 and above we are not able to login server with SSH password. but when we try to login with key then it all...