LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-19-2016, 02:31 AM   #1
English_Man
Member
 
Registered: Feb 2004
Location: Stockholm SWEDEN
Distribution: Ubuntu server 15.10
Posts: 60

Rep: Reputation: 15
Cron using a command that asks for password


I am using an encrypted amazon cloud drive as a source drive for using the same files on many different machines. I have it mounted on several Ubuntu machine and everything works fine, but in order to update the local cache it needs to be unmounted.

These machines only read from the cloud, the source material is uploaded via another machine.

I need some help making a cron task or script that will run every hour and first unmount the encrypted fs, update the local cache, remount the cloud and remount the encfs on top.

When I use encfs from the command line, I use a xml encryption file and then it prompts for the master password.

Quote:
ENVIRONMENT VARIABLES
ENCFS6_CONFIG
Which config file (typically named .encfs6.xml) to use. By
default, the config file is read from the encrypted directory.
Using this option allows to store the config file separated from
the encrypted files.

Warning: If you lose the config file, the encrypted file contents
are irrecoverably lost. It contains the master key encrypted with
your password. Without the master key, recovery is impossible, even
if you know the password.
I use the following commands to unmount the cloud and encfs:

Code:
/bin/fusermount -u /home/user/.cloud 

/bin/fusermount -u /home/user/cloud
Then update the local cache using the following command:

Code:
/usr/local/bin/acd_cli s
Then mount the cloud storage again:

Code:
/usr/local/bin/acd_cliacd_cli mount --modules="subdir,subdir=/Ww4hiiFIGcL50MEsUcd2NI4e" /home/user/.cloud
Then setup the decryption:

Code:
ENCFS6_CONFIG='/home/user/1.Important.files/.encfs6.xml' encfs /home/user/.cloud /home/user/cloud
The problem I have is that the last command asks for a password to be entered, is there anyway of making it read the password from a file or worst case scenario, hard code the password in the script.

Hopefully someone will be able to help me with this.

Thanks in advance.

Last edited by English_Man; 03-19-2016 at 10:04 AM. Reason: Problem solved. To include more information about my setup
 
Old 03-19-2016, 07:07 AM   #2
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,674

Rep: Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712Reputation: 2712
What have you done so far?

Did you check the man pages and documentation for encfs?

Since it can be set to automount on boot, there must be a way for it to pick up the password without prompting.

If you do not find that way, may I suggest the use of something like 'expect' to provide that capability.

Be aware that if you provide the password in an expect script, or in some config file, it does make the entire operation a little less secure. (since it will add either unencrypted passwords in a file, or an additional encrypted copy that may be vulnerable to detection and decryption).
 
Old 03-19-2016, 07:25 AM   #3
English_Man
Member
 
Registered: Feb 2004
Location: Stockholm SWEDEN
Distribution: Ubuntu server 15.10
Posts: 60

Original Poster
Rep: Reputation: 15
I have checked the man pages and didn't see anything about the auto mount using config files.

On closer inspection, I found the following option;

Quote:
-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.
So, I think the following command should work;

Code:
cat /home/user/.password | ENCFS6_CONFIG='/home/user/1.Important.files/.encfs6.xml' encfs -S /home/user/.cloud /home/user/cloud
I am not infront of a system right now, but ill give it a try in a few hours and report back.

Last edited by English_Man; 03-19-2016 at 07:42 AM.
 
Old 03-19-2016, 07:41 AM   #4
kubuntu-man
Member
 
Registered: Oct 2011
Posts: 36

Rep: Reputation: Disabled
from the encfs man page (http://linux.die.net/man/1/encfs):

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

If you don't have this option, your version my be too old.
 
Old 03-19-2016, 10:03 AM   #5
English_Man
Member
 
Registered: Feb 2004
Location: Stockholm SWEDEN
Distribution: Ubuntu server 15.10
Posts: 60

Original Poster
Rep: Reputation: 15
Using the -S option works.

It's a little bit unsecured because I have the password in plaintext in a file, but I will do my best to hide it and continue looking for a safer alternative.

But right now, it does what I wanted it to do.

Thanks for the interest and help.
 
  


Reply

Tags
cloud, cron, encfs, fuse, password



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] PDF file asks for password but its not password protected? M$ISBS Linux - General 3 01-19-2015 07:47 PM
[SOLVED] SSH: Asks for password: Permission denied (keyboard-interactive,password). tulicloure Linux - Newbie 7 02-14-2012 09:48 AM
Running a command on a remote server asks for password (debian) zakzy Linux - Server 9 07-11-2011 06:37 AM
[SOLVED] Sudo command occasionally asks for root password ubuntuv Linux - Newbie 25 09-14-2010 01:26 PM
Running Command in Cron without giving away password DJOtaku Linux - Security 8 11-17-2009 07:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration