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
Line 6: Line 6:
#!/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 26:
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 44: Line 58:
exit 0
exit 0
</pre>
</pre>




<yambe:breadcrumb>Useful_bash_shell_scripts|Useful bash shell scripts</yambe:breadcrumb>
<yambe:breadcrumb>Useful_bash_shell_scripts|Useful bash shell scripts</yambe:breadcrumb>

Revision as of 06:21, 15 February 2013

<yambe:breadcrumb>Useful_bash_shell_scripts|Useful bash shell scripts</yambe:breadcrumb>

Mount encryped 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


<yambe:breadcrumb>Useful_bash_shell_scripts|Useful bash shell scripts</yambe:breadcrumb>