Mount encrypted filesystems
From Notes_Wiki
Home > Shell scripting > Useful bash shell scripts > Mount encrypted filesystems
Following script can be used for mounting many different encrypted filesystems that use same password:
#!/bin/bash while : do read -s -p "Password: " PASSWORD sshpass -p "$PASSWORD" sudo encfs --public /mnt/data1/raw_folders/backup_raw /mnt/data1/backup_snapshots echo echo -n "Was password incorrect (y/n) : " read VAL1 if [[ "$VAL1" = "n" || "$VAL1" = "N" ]] ; then break fi echo done sshpass -p "$PASSWORD" sudo encfs --public /mnt/data1/raw_folders/documents_raw /documents sudo /sbin/service httpd start /documents/room-documents/documents/programs/erlang/web_application/start_yaws.sh sshpass -p "$PASSWORD" sudo encfs --public /mnt/data1/raw_folders/personal_raw /mnt/personal sshpass -p "$PASSWORD" sudo encfs --public /var/lib/mysql_raw /var/lib/mysql sudo /sbin/service mysqld start sshpass -p "$PASSWORD" sudo encfs --public /var/lib/pgsql_raw /var/lib/pgsql sudo /sbin/service postgresql start sshpass -p "$PASSWORD" sudo encfs --public /mnt/data1/raw_folders/virtual_labs_raw /mnt/data1/virtual_labs echo "Mounting of encrypted folders complete." exit 0
However, if the different folders use different encryption password then following script can be used instead:
#!/bin/bash function mount_encfs() { while : do echo "Enter encfs password for $2 : " sudo encfs --public $1 $2 echo -n "Rerun encfs for $2 (y/n) : " read VAL1 if [[ "$VAL1" = "n" || "$VAL1" = "N" ]] ; then break fi echo done } mount_encfs /mnt/data1/raw_folders/documents_raw /documents mount_encfs /mnt/data1/raw_folders/personal_raw /personal exit 0
Home > Shell scripting > Useful bash shell scripts > Mount encrypted filesystems