|
|
Subject:
encryption of directories in linux
Category: Computers > Software Asked by: skks-ga List Price: $10.00 |
Posted:
19 Jun 2002 11:43 PDT
Expires: 26 Jun 2002 11:43 PDT Question ID: 29290 |
What is a good program in unix/linux to encrypt/decrypt files and whole directories ... for example i have seen in freshmeat a program called ccrypt and another called mcrypt. There is also gnupg but i dont think it can encrypt recursively directories. I am looking for open source and free programs I do not want to use zip (pkzip) since that does archiving into a single file which i dont like. What seems to be the most popular or best method? I would like someone who has experience with this subject to answer if at all possible. |
|
Subject:
Re: encryption of directories in linux
Answered By: runix-ga on 19 Jun 2002 15:10 PDT |
skks: I've coded 2 little scripts that recursively encrypt all the files in a directory in different files (called filename.crypted). The program used to encrypt the files is 'mcrypt' on the mcrypt package. The first one is called 'encrypt': #!/bin/bash stty -echo echo -n "Enter your password: " read passwd stty echo # Restores screen echo. echo echo for file in `find ./ -type 'f'|grep -v -E "\.crypted$"`; do dest="${file}.crypted" if [ "$dest" != "$file" ]; then echo -n "Crypting $file to $dest... " if ( cat "$file"|mcrypt -q -k $passwd > "$dest" ); then echo " OK!" echo " Deleting $file" if ( rm -f "$file" ); then echo "OK!" else echo "Error!" fi else echo " Error!" fi else echo "$file is crypted!" fi done -------------- The second one, is called 'decrypt': #!/bin/bash stty -echo echo -n "Enter your password: " read passwd stty echo # Restores screen echo. echo echo for file in `find ./ -type 'f'|grep -E "\.crypted$"`; do dest=`echo $file|sed -e 's/\.crypted$//'` if [ "$dest" != "$file" ]; then echo -n "Decrypting $file to $dest... " if ( cat "$file"|mdecrypt -q -k $passwd > "$dest" ); then echo " OK!" echo " Deleting $file" if ( rm -f "$file" ); then echo "OK!" else echo "Error!" fi else echo " Error!" fi fi done ---- Please make a backup of your files before testing the script! Additional links: mcrypt in a RPM package: http://www.rpmfind.net/linux/rpm2html/search.php?query=mcrypt&submit=Search+... mcrypt in DEB packages: http://packages.debian.org/cgi-bin/search_packages.pl?keywords=mcrypt&searchon=all&subword=1&version=all&release=all mcrypt homepage: http://mcrypt.hellug.gr/#_mcrypt | |
| |
| |
|
|
Subject:
Re: encryption of directories in linux
From: pierpa-ga on 19 Jun 2002 14:20 PDT |
It's very easy, as anything in Linux :-) You just need an encrypted file that will become an encrypted tree of files, or a directory if you prefer to depict it this way. This "tree" or "directory" can be mounted everywhere: under your home directory if you like. Before mounting it you will need a password and/or a private key to access its content, otherwise it will remain a useless file in your home directory. Once mounted (i.e. once given the necessary credentials) you will be able to use it as any other filesystem you mount in your filesystem. You can even email it or backup in CD-RW. The whole procedure is fully explained at this link: http://www.tldp.org/HOWTO/Loopback-Encrypted-Filesystem-HOWTO.html Hope this helps, Greetings, ppp |
Subject:
Re: encryption of directories in linux
From: simac-ga on 22 Jun 2002 19:08 PDT |
Did it ever occur to any of you to simply tar the directory, then encrypt it (tar -c directory | mcrypt -k password > file), (cat file | mdecrypt -k | tar -x)? Just a thought. |
Subject:
Re: encryption of directories in linux
From: runix-ga on 23 Jun 2002 08:23 PDT |
simac: Skks said: "I do not want to use zip (pkzip) since that does archiving into a single file which i dont like. " |
Subject:
Re: encryption of directories in linux
From: novel-ga on 31 May 2004 19:49 PDT |
I was looking on google for references of mcrypt and found your script. but i found that it can be improved cause as long as it asks one time for the password (on the encryption) you can misstype a letter and get your files completely lost, also you have to be on the directory that you want to encrypt, and also if you have files with spaces (example: im\ novel.txt) you will get an error and wont work the program. So i modified yours and decided to post it for everyone. -- My encrypter version - #!/bin/bash IFS=' ' if [[ -z $1 ]] then echo "Use: cryptdir [directory]" exit else [ -x $1 ] && busc=1 if [[ $busc == 1 ]] then echo "Directory to Encrypt... ˇFound!" else echo -e "Directory to Encrypt... ˇNot Found!" exit fi busc=0 echo "$1 will be encrypted" fi stty -echo echo -n "Password: " read passwd stty echo echo stty -echo echo -n "Reenter Password: " read passwd2 stty echo echo if [[ $passwd != $passwd2 ]] then echo "Password missmatch" exit else echo "The password is the same" fi for file in `find $1 -type 'f'|grep -v -E "\.crypted$"`; do dest="${file}.crypted" if [ "$dest" != "$file" ]; then echo -n "Encryptando $file a $dest... " if ( cat "$file"|mcrypt -a blowfish -q -k $passwd > "$dest" ); then echo " OK!" echo " Deleting $file" if ( rm -f "$file" ); then echo "OK!" else echo "Error!" fi else echo " Error!" fi else echo "$file is encrypted!" fi done -- My decrypter version -- #!/bin/bash IFS=' ' if [[ $1 == "" ]] then echo "Use: decryptdir [directory]" exit else [ -x $1 ] && busc=1 if [[ $busc == 1 ]] then echo "Directory to Encrypt... ˇFound!" else echo -e "Directory to Encrypt... ˇNot Found!" exit fi busc=0 echo "$1 will be decrypted" fi stty -echo echo -n "Password: " read passwd stty echo echo for file in `find $1 -type 'f'|grep -E "\.crypted$"`; do dest=`echo $file|sed -e 's/\.crypted$//'` if [ "$dest" != "$file" ]; then echo -n "Decrypting $file to $dest... " if ( cat "$file"|mdecrypt -q -k $passwd > "$dest" ); then echo " OK!" echo " Deleting $file" if ( rm -f "$file" ); then echo "OK!" else echo "Error!" fi else echo " Error!" fi fi done |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |