Bash script to automate truecrypt volume creation, mounting and unmounting

6,236

Solution 1

Use the --password=password flag to pass a random/set password through.

I would also use the --non-interactive flag so nothing interrupts the automation process.

Here is a list of all available commands to use with truecrypt:

http://www.irongeek.com/i.php?page=backtrack-3-man/truecrypt

Solution 2

At last I got the solution. I shall provide it here so that it may assist someone else in future.
Before scripting with truecrypt always keep in mind the version number.
The solution worked with charm for version 7.1a
Can't comment about other versions.

Here is the command to create a truecrypt volume without prompting the user to enter any parameters:

truecrypt -t --size=1074000000 --password=123 -k "" --random-source=/dev/urandom --volume-type=normal --encryption=AES --hash=SHA-512 --filesystem=FAT -c myvolume.tc

NOTE: This is an insecure method as password is visible!!!

Share:
6,236

Related videos on Youtube

ρss
Author by

ρss

Do you have a question?

Updated on September 18, 2022

Comments

  • ρss
    ρss over 1 year

    I am trying to code a bash script that will automate the several tasks related to truecrypt. Tasks are: Creating a truecrypt volume, mounting it, copying a file in filesystem, modifying the file, unmounting the volume.

    I have a question regarding creating the truecrypt volume. mounting and unmounting will not be a problem for me.

    The command for creating volume is according to manpages:

    > truecrypt -c [volume path]
    

    but after this command trucrypt will prompt user to enter several parameters like volume type, size, encryption, hash, password etc.

    How can automate all these so that user doesn't need to enter any value? Ok I can use following command for this:

    truecrypt –size 200M –type normal –encryption AES –hash SHA-512 –filesystem FAT -c myvolume.tc
    

    But now it asks for password. How to automate that?

    Thanks

    • Mahesh
      Mahesh over 11 years
      expect is what you need. There may be easier ways, but thats what comes to my mind.
  • ρss
    ρss over 11 years
    Hey taang, I think we just posted almost at the same time. ;) Still thanks.
  • Tomáš Fejfar
    Tomáš Fejfar almost 11 years
    and what would be secure way of doing this - without visible password?