Page 1 of 1

Passing password to encfs

PostPosted: Mar 14th, '15, 19:43
by mackowiakp
There is an option in encfs:

Code: Select all
--extpass=program     Use external program for password prompt


I want to use such program for this:

Code: Select all
#!/bin/bash
zenity --entry --title="password dialog" --text="Enter your _password:" --hide-text


But how can I pass such obtained password to encfs call?
Any idea?

Re: Passing password to encfs

PostPosted: Mar 14th, '15, 20:20
by doktor5000
Did you read the manpage?

https://github.com/vgough/encfs/blob/master/encfs/encfs.pod wrote:--extpass=program
Specify an external program to use for getting the user password. When the external program is spawned, the environment variable "RootDir" will be set to contain the path to the root directory. The program should print the password to standard output.

EncFS takes everything returned from the program to be the password, except for a trailing newline (\n) which will be removed.

For example, specifying --extpass=/usr/lib/ssh/ssh-askpass will cause EncFS to use ssh's password prompt program.

Note: EncFS reads at most 2k of data from the password program, and it removes any trailing newline. Versions before 1.4.x accepted only 64 bytes of text.

-S, --stdinpass
Read password from standard input, without prompting. This may be useful for scripting encfs mounts.

Note that you should make sure the filesystem and mount points exist first. Otherwise encfs will prompt for the filesystem creation options, which may interfere with your script.

Re: Passing password to encfs

PostPosted: Mar 15th, '15, 10:18
by mackowiakp
Yes, I read it. So I try like this:

Code: Select all
pass=`zenity --entry --title="password dialog" --text="Enter your _password:" --hide-text`
sudo encfs -S --public /home/maciek/dir/.dir_c /home/maciek/dir_v < `echo $pass`


But it returns:

Code: Select all
line 2: <password>: No such file or directory

Re: Passing password to encfs

PostPosted: Mar 15th, '15, 11:31
by mackowiakp
OK. Finally I got it working.

Main script loos like this:

Code: Select all
#!/bin/bash
sudo encfs --extpass=/home/maciek/Pobrane/zen --public /home/maciek/dir/.dir_c /home/maciek/dir_v >/dev/null 2>/dev/null
status=$?
if test $status -eq 0
then
mount /home/maciek/.ssh
zenity --timeout=10 --info --text "Połączono SSH"
exit
else
umount /home/maciek/.ssh 2>/dev/null
sudo fusermount -u ~/dir_v 2>/dev/null
zenity --timeout=10 --error --text "Rozłączono SSH lub błędne hasło"
fi


Where "zen" script is:

Code: Select all
#!/bin/bash
xhost local:maciek > /dev/null
zenity --entry --title="password dialog" --text="wprowaź hasło do SSH:" --hide-text


So i placed icon on pulpit, linked to main script. But I must set in options "Run in terminal". In other case, script always fails that is "zen" script does not start.
Is any possibility to hide or turn off terminal window during call such script?