Tiny Core Linux

Tiny Core Base => Micro Core => Topic started by: remus on May 25, 2017, 06:31:17 PM

Title: password protecting a file via bash script ?
Post by: remus on May 25, 2017, 06:31:17 PM
Hi all,

I'm trying to figure out how to password protect a file from a shell script, before uploading it to google drive for offsite backup.

I can't find reference about passing a password to bcrypt in the bcrypt command, it seems to want interaction...

Any comments and suggestions welcome.

Thanks.
Title: Re: password protecting a file via bash script ?
Post by: Rich on May 25, 2017, 06:41:14 PM
Hi remus
Try this:
Code: [Select]
yes PASSWORD | bcrypt FILENAME
Title: Re: password protecting a file via bash script ?
Post by: remus on May 25, 2017, 06:58:58 PM
Thx rich, works well.

Does bcrypt have a file integrity testing option like 7zip does ?

I just realised that it would be great to be able to run an integrity test on the file before uploading it.

Title: Re: password protecting a file via bash script ?
Post by: Rich on May 25, 2017, 07:08:43 PM
Hi remus
Quote
Does bcrypt have a file integrity testing option like 7zip does ?
The programs usage doesn't mention it:
Code: [Select]
tc@box:~$ bcrypt
Usage is: bcrypt -[orc][-sN] file1 file2..
  -o Write output to standard out
  -r Do NOT remove input files after processing
  -c Do NOT compress files before encryption
  -sN How many times to overwrite input files with random data
tc@box:~$
Title: Re: password protecting a file via bash script ?
Post by: remus on May 25, 2017, 07:42:38 PM
I noticed that too Rich.

So I've done a little searching and discovered zip-unzip.tcz

And have come up with this.

zip -P password file.zip file.txt (Will create a password protected file with password as the password)

unzip -t -P password file.zip (Will test my archive, and I'm passing the password to it)

These commands will do for what I need. I know this approach has a few security flaw's. But It will do. I'm not dealing with national secrets.