Archive and encrypt a directory from terminal [example]

I want to back up my SSH keys using Dropbox. Since the NSA will get and abuse my private key I have to encrypt ~/.ssh when using cloud services.

This is very easy to accomplish:
Archive directory and pipe the tarball to GPG for encryption. Please remember to use a strong passphrase.

$ tar -vcz ~/.ssh  | gpg -c > ssh.tgz.gpg

v – verbose
c – create new archive
z – compress using gzip
c – symmetric encryption

Execute the following to restore.

$ gpg -d ssh.tgz.gpg | tar vxz

d – decrypt
v – verbose
x – extract files from archive
z – decompress using gzip

The directory tree will be restored as well.
This is an example and may be applied anywhere.

Advertisements
This entry was posted in english, Verschlüsselung and tagged , , , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s