Difference between revisions of "Mount encrypted filesystems"

From Notes_Wiki
(Created page with "<yambe:breadcrumb>Useful_bash_shell_scripts|Useful bash shell scripts</yambe:breadcrumb> =Mount encryped filesystems= Following script can be used for mounting many different...")
 
m
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
<yambe:breadcrumb>Useful_bash_shell_scripts|Useful bash shell scripts</yambe:breadcrumb>
[[Main_Page|Home]] > [[Shell scripting]] > [[Useful bash shell scripts]] > [[Mount encrypted filesystems]]
=Mount encryped filesystems=


Following script can be used for mounting many different encrypted filesystems that use same password:
Following script can be used for mounting many different encrypted filesystems that use same password:
Line 6: Line 5:
#!/bin/bash
#!/bin/bash


read -s -p "Password: " PASSWORD
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
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 /mnt/data1/raw_folders/personal_raw /mnt/personal
sshpass -p "$PASSWORD" sudo encfs --public /var/lib/mysql_raw  /var/lib/mysql
sshpass -p "$PASSWORD" sudo encfs --public /var/lib/mysql_raw  /var/lib/mysql
Line 13: Line 25:
sshpass -p "$PASSWORD" sudo encfs --public /var/lib/pgsql_raw  /var/lib/pgsql
sshpass -p "$PASSWORD" sudo encfs --public /var/lib/pgsql_raw  /var/lib/pgsql
sudo /sbin/service postgresql start
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."
echo "Mounting of encrypted folders complete."
Line 46: Line 59:




 
[[Main_Page|Home]] > [[Shell scripting]] > [[Useful bash shell scripts]] > [[Mount encrypted filesystems]]
<yambe:breadcrumb>Useful_bash_shell_scripts|Useful bash shell scripts</yambe:breadcrumb>

Latest revision as of 13:39, 7 April 2022

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