{"id":1271,"date":"2018-11-04T16:08:06","date_gmt":"2018-11-04T13:08:06","guid":{"rendered":"http:\/\/kifarunix.com\/?p=1271"},"modified":"2024-03-11T21:38:30","modified_gmt":"2024-03-11T18:38:30","slug":"how-to-use-veracrypt-on-command-line-to-encrypt-drives-on-ubuntu","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/how-to-use-veracrypt-on-command-line-to-encrypt-drives-on-ubuntu\/","title":{"rendered":"How to Use VeraCrypt on Command Line to Encrypt Drives on Ubuntu"},"content":{"rendered":"\n
In this tutorial, you will learn how to use VeraCrypt on Command Line to Encrypt Drives on Ubuntu. In our previous article, we discussed how to install and use VeraCrypt to encrypt drives on Ubuntu<\/a>.<\/p>\n\n\n\n We used the VeraCrypt GUI method. In this article, we are going to learn how to use VeraCrypt on command line interface to achieve the same encryption.<\/p>\n\n\n\n To run VeraCrypt in text user interface, just type The command line synopsis of the To learn more about VeraCrypt command line options, run With VeraCrypt, you can create two types of volumes;<\/p>\n\n\n\n While creating each volume, you can choose to use an unused partition or just create a file-based volume to store your data.<\/p>\n\n\n\n Launch When you run the command, you are prompted to choose the type of volume. In this case, we are going to setup a Normal volume.<\/p>\n\n\n\n Next, enter the volume path. For example, \/dev\/sdb1.<\/p>\n\n\n\n CAUTION: If you are encrypting a partition, ensure that there is no data in it or the data has been backed up and backup confirmed. The process will wipe the partition clean and you will all data, if any was stored in it.<\/strong><\/p>\n\n\n\n Note that I have unused partition, Thus, if you are using a partition, enter the device;<\/p>\n\n\n\n Define the Encryption as well as the hashing algorithms;<\/p>\n\n\n\n We choose the AES and SHA 512 as encryption and hashing algorithms respectively. You can also just press enter to accept the defaults.<\/p>\n\n\n\n Define the filesystem to format the volume with.<\/p>\n\n\n\n In this case, we are going with Linux Ext4<\/strong>.<\/p>\n\n\n\n Next<\/p>\n\n\n\n To create the outer volume in non-interactive mode, run the command below;<\/p>\n\n\n\n Once the outer volume is created, you need to create the hidden volume within it. So repeat the above procedure but this time round;<\/p>\n\n\n\n To create a hidden volume in non-interactive mode, run the command below;<\/p>\n\n\n\n Once you are done creating the volumes, you can now mount them and write your files or data to them as you wish.<\/p>\n\n\n\n To mount the outer volume, run the command below. When prompted for a password, use the password set for the outer volume above.<\/p>\n\n\n\n Password wizard pops up to enter the outer volume encrypted password.<\/p>\n\n\n\n Once mounted, verify.<\/p>\n\n\n\n To mount otvolume prompting only for its password:<\/p>\n\n\n\n List the mounted VeraCrypt volumes.<\/p>\n\n\n\n To unmount the volume,<\/p>\n\n\n\n To mount the hidden volume, run veracrypt command as shown above but this time, use the password defined for the hidden volume<\/strong>.<\/p>\n\n\n\n Seen how easy it is to use VeraCrypt on command line to encrypt your storage volumes? You can now create or put your sensitive data into the hidden volume. Enjoy the power of encryption.<\/p>\n\n\n\n That conclude our guide on how to use VeraCrypt on Command Line to Encrypt Drives on Ubuntu.<\/p>\n\n\n\n Encrypt Files and Directories with eCryptFS on Ubuntu 20.04<\/a><\/p>\n\n\n\nUsing VeraCrypt to Encrypt Drives on Command Line<\/h2>\n\n\n\n
veracrypt<\/code> <\/strong>and pass the -t\/–text<\/strong> option.<\/p>\n\n\n\n
veracrypt<\/code> <\/strong>command is;<\/p>\n\n\n\n
veracrypt [OPTIONS] COMMAND\nveracrypt [OPTIONS] VOLUME_PATH [MOUNT_DIRECTORY]<\/code><\/pre>\n\n\n\n
veracrypt -h<\/code><\/strong>.<\/p>\n\n\n\n
\n
Create VeraCrypt Outer Volume on Command Line<\/h3>\n\n\n\n
veracrypt<\/code><\/strong> command from the terminal and pass option -c\/–create<\/strong> and of course the -t\/–text<\/strong> option. Most of the options will be requested if you don’t specify them on the command line and thus the setup becomes interactive.<\/p>\n\n\n\n
sudo veracrypt -t -c<\/code><\/pre>\n\n\n\n
Volume type:\n 1) Normal\n 2) Hidden\nSelect [1]: 1<\/code><\/pre>\n\n\n\n
\/dev\/sdb1<\/code><\/strong>.<\/p>\n\n\n\n
lsblk<\/code><\/pre>\n\n\n\n
\nNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT\nsda 8:0 0 20G 0 disk \n\u2514\u2500sda1 8:1 0 20G 0 part \/\nsdb 8:16 0 4G 0 disk \n\u2514\u2500sdb1 8:17 0 4G 0 part <\/strong>\nsr0 11:0 1 1024M 0 rom \nsr1 11:1 1 1024M 0 rom\n<\/code><\/pre>\n\n\n\n
Enter volume path: \/dev\/sdb1<\/strong><\/code><\/pre>\n\n\n\n
\nEncryption Algorithm:\n 1) AES\n 2) Serpent\n 3) Twofish\n 4) Camellia\n 5) Kuznyechik\n 6) AES(Twofish)\n 7) AES(Twofish(Serpent))\n 8) Camellia(Kuznyechik)\n 9) Camellia(Serpent)\n 10) Kuznyechik(AES)\n 11) Kuznyechik(Serpent(Camellia))\n 12) Kuznyechik(Twofish)\n 13) Serpent(AES)\n 14) Serpent(Twofish(AES))\n 15) Twofish(Serpent)\nSelect [1]: 1\n\nHash algorithm:\n 1) SHA-512\n 2) Whirlpool\n 3) SHA-256\n 4) Streebog\nSelect [1]: 1\n\n<\/code><\/pre>\n\n\n\n
\nFilesystem:\n 1) None\n 2) FAT\n 3) Linux Ext2\n 4) Linux Ext3\n 5) Linux Ext4\n 6) NTFS\n 7) exFAT\nSelect [2]: 5<\/strong>\n<\/code><\/pre>\n\n\n\n
\n
\nEnter password: Enter STRONGPASSWORD<\/strong>\nRe-enter password: Re-Enter STRONGPASSWORD<\/strong>\n\nEnter PIM: Enter<\/strong>\n\nEnter keyfile path [none]: Enter<\/strong>\n\nPlease type at least 320 randomly chosen characters and then press Enter:\n<PASTE OR TYPE 320 CHARACTERS HERE ><\/strong>\n\nDone: 100.000% Speed: 54 MB\/s Left: 0 s \n\nThe VeraCrypt volume has been successfully created.\n<\/code><\/pre>\n\n\n\n
sudo veracrypt -t -c --volume-type=normal \/dev\/sdb1 \\\n--encryption=aes --hash=sha-512 --filesystem=ext4 \\\n-p STRONGP@33WORD --pim=0 -k \"\" --random-source=\/dev\/urandom<\/code><\/pre>\n\n\n\n
Create Hidden Volume within the Outer volume<\/h3>\n\n\n\n
sudo veracrypt -t -c<\/code><\/pre>\n\n\n\n
\n
\nVolume type:\n 1) Normal\n 2) Hidden\nSelect [1]: 2\n\nIMPORTANT: Inexperienced users should use the graphical user interface to create a hidden volume. When using the text interface, the procedure described in the command line help must be followed to create a hidden volume.\n\nEnter volume path: \/dev\/sdb1\n\nEnter hidden volume size (sizeK\/size[M]\/sizeG\/sizeT\/max): 1G\n\nEncryption Algorithm:\n 1) AES\n 2) Serpent\n 3) Twofish\n 4) Camellia\n 5) Kuznyechik\n 6) AES(Twofish)\n 7) AES(Twofish(Serpent))\n 8) Camellia(Kuznyechik)\n 9) Camellia(Serpent)\n 10) Kuznyechik(AES)\n 11) Kuznyechik(Serpent(Camellia))\n 12) Kuznyechik(Twofish)\n 13) Serpent(AES)\n 14) Serpent(Twofish(AES))\n 15) Twofish(Serpent)\nSelect [1]: 1\n\nHash algorithm:\n 1) SHA-512\n 2) Whirlpool\n 3) SHA-256\n 4) Streebog\nSelect [1]: 1\n\nFilesystem:\n 1) None\n 2) FAT\n 3) Linux Ext2\n 4) Linux Ext3\n 5) Linux Ext4\n 6) NTFS\n 7) exFAT\n 8) Btrfs\nSelect [2]: 5\n\nEnter password: STRONGPASSWORDFORHIDDENVOLUME<\/strong>\nRe-enter password: STRONGPASSWORDFORHIDDENVOLUME<\/strong>\n\nEnter PIM: Enter \n\nEnter keyfile path [none]: Enter\n\nPlease type at least 320 randomly chosen characters and then press Enter:\n<PASTE YOUR 320 CHARACTERS HERE ><\/strong>\n\nDone: 100.000% Speed: 256 MB\/s Left: 0 s \n\nThe hidden VeraCrypt volume has been successfully created and is ready for use. If all the instructions have been followed and if the precautions and requirements listed in the section \"Security Requirements and Precautions Pertaining to Hidden Volumes\" in the VeraCrypt User's Guide are followed, it should be impossible to prove that the hidden volume exists, even when the outer volume is mounted.\n\nWARNING: IF YOU DO NOT PROTECT THE HIDDEN VOLUME (FOR INFORMATION ON HOW TO DO SO, REFER TO THE SECTION \"PROTECTION OF HIDDEN VOLUMES AGAINST DAMAGE\" IN THE VERACRYPT USER'S GUIDE), DO NOT WRITE TO THE OUTER VOLUME. OTHERWISE, YOU MAY OVERWRITE AND DAMAGE THE HIDDEN VOLUME!\n<\/code><\/pre>\n\n\n\n
sudo veracrypt -t -c --volume-type=hidden \/dev\/sdb2 \\\n--size=500M --encryption=aes --hash=sha-512 \\\n--filesystem=ext4 -p STRONGP@33WORDHID --pim=0 \\\n-k \"\" --random-source=\/dev\/urandom<\/code><\/pre>\n\n\n\n
Mount the VeraCrypt Outer and Inner Volumes<\/h3>\n\n\n\n
sudo veracrypt \/dev\/sdb1 \/mnt\/<\/code><\/pre>\n\n\n\n
df -hT \/mnt<\/code><\/pre>\n\n\n\n
Filesystem Type Size Used Avail Use% Mounted on\n\/dev\/mapper\/veracrypt1 ext4 3.9G 16M 3.7G 1% \/mnt<\/code><\/pre>\n\n\n\n
sudo veracrypt -t -k \"\" --pim=0 --protect-hidden=no \/dev\/sdb1 \/mnt\/sdb1\/<\/code><\/pre>\n\n\n\n
veracrypt -l<\/code><\/pre>\n\n\n\n
1: \/dev\/sdb1 \/dev\/mapper\/veracrypt1 \/mnt\/<\/code><\/pre>\n\n\n\n
sudo veracrypt -d \/dev\/sdb1<\/code><\/pre>\n\n\n\n
Other Tutorials<\/h2>\n\n\n\n