Passing password to encfs

This forum is dedicated to basic help and support :

Ask here your questions about basic installation and usage of Mageia. For example you may post here all your questions about getting Mageia isos and installing it, configuring your printer, using your word processor etc.

Try to ask your questions in the right sub-forum with as much details as you can gather. the more precise the question will be, the more likely you are to get a useful answer

Passing password to encfs

Postby mackowiakp » Mar 14th, '15, 19:43

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?
Linux is like wigwam. No Windows, no Gates but Apache inside

WARNING ! The administrator has the right to refuse to install WINDOWS, invoking the conscience clause
mackowiakp
 
Posts: 660
Joined: May 23rd, '13, 07:32
Location: Gdynia, Poland

Re: Passing password to encfs

Postby doktor5000 » Mar 14th, '15, 20:20

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.
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 18059
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: Passing password to encfs

Postby mackowiakp » Mar 15th, '15, 10:18

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
Linux is like wigwam. No Windows, no Gates but Apache inside

WARNING ! The administrator has the right to refuse to install WINDOWS, invoking the conscience clause
mackowiakp
 
Posts: 660
Joined: May 23rd, '13, 07:32
Location: Gdynia, Poland

Re: Passing password to encfs

Postby mackowiakp » Mar 15th, '15, 11:31

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?
Linux is like wigwam. No Windows, no Gates but Apache inside

WARNING ! The administrator has the right to refuse to install WINDOWS, invoking the conscience clause
mackowiakp
 
Posts: 660
Joined: May 23rd, '13, 07:32
Location: Gdynia, Poland


Return to Basic support

Who is online

Users browsing this forum: No registered users and 1 guest