LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 08-15-2012, 05:12 AM   #1
newize
LQ Newbie
 
Registered: Sep 2009
Posts: 6

Rep: Reputation: 0
Copying files encrypted with ecryptfs


Hi. I am trying to use ecryptfs for the first time.
I've created /mnt/backup/secret/ and /mnt/backup/plain/
and copied a directory (called '6') into /mnt/backup/plain/
Now I want to copy this encrypted dir /mnt/backup/secret/6/
to my Dropbox folder.

But using cp -av just copies the bare dir structure with no
actual encrypted files. Same with rsync. sudo makes no difference.
I get

cp: cannot open `6/lists.tex' for reading: Input/output error

errors. This also occurs with target dirs outside the Dropbox.

I don't know where to begin with this. Using Ubuntu 11.04
 
Old 08-15-2012, 11:57 PM   #2
Quantumstate
Member
 
Registered: Jun 2005
Location: Seattle, Ecotopia
Distribution: CentOS 7.4 with KDE
Posts: 262

Rep: Reputation: 22
Please use sshfs. You can remotely mount a filesystem by putting this in fstab:
Code:
sshfs#{user}@remotehost:/	/media/{localmountpoint}	fuse	user,auto,_netdev,cache=no,ServerAliveInterval=15,reconnect,allow_other,comment=sshfs 0 0
 
Old 08-16-2012, 10:05 AM   #3
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,784

Rep: Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214
Try unmounting the ecryptfs filesystem first. From the ecryptfs FAQ:
Q. Can I access the lower files while eCryptfs is mounted?

Accessing the lower files during an active eCryptfs mount is somewhat like accessing a block device on which ext3 is mounted. The kernel allows it, and it may work (depending on what you do with the data), but it is not a good idea.
 
1 members found this post helpful.
Old 08-17-2012, 08:31 AM   #4
newize
LQ Newbie
 
Registered: Sep 2009
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by rknichols View Post
Try unmounting the ecryptfs filesystem first. From the ecryptfs FAQ:
Q. Can I access the lower files while eCryptfs is mounted?

Accessing the lower files during an active eCryptfs mount is somewhat like accessing a block device on which ext3 is mounted. The kernel allows it, and it may work (depending on what you do with the data), but it is not a good idea.
Thanks for this. (I'd read it, but not understood it.)

I tried this, but get `device is busy' messages.

I don't understand why moving or copying the files is difficult. The manpage says, right at the start,
Quote:
eCryptfs stores cryptographic metadata in the header of each file written, so that encrypted files can be copied between hosts;
so surely it ought to be easy to do?

I also tried mount --move /mnt/backup/secret /home/myname/Dropbox
This shifted the dir tree, but not the files, to Dropbox and made inaccessible the usual contents of Dropbox.

Maybe I should try sshfs as suggested above, or set up a vpn server on my home machine. What
I want to be able to do is the following: I use two desktops, home and office, a heavy laptop, a tablet, plus other desktops when I travel abroad. My Dropbox has about 30GB of stuff which can safely be kept in plain. I have another few GB of private stuff which I need to be able to get at, and edit, while away from the home machine. ecryptfs seemed like a good solution ...
 
Old 08-17-2012, 01:08 PM   #5
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,784

Rep: Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214
"Device is busy" means that some process has a file open or has its current working directory somewhere in the mounted (plaintext) directory. It's the same issue you'd run into if unmounting any other filesystem.

You could also try remounting the filesystem read-only:
Code:
mount -o remount,ro /mnt/backup/plain
That will be allowed unless there is a file open for writing or a file that is unlinked but still in use by some process.
 
Old 08-18-2012, 06:35 AM   #6
Reuti
Senior Member
 
Registered: Dec 2004
Location: Marburg, Germany
Distribution: openSUSE 15.2
Posts: 1,339

Rep: Reputation: 260Reputation: 260Reputation: 260
Quote:
Originally Posted by rknichols View Post
"Device is busy" means that some process has a file open or has its current working directory somewhere in the mounted (plaintext) directory. It's the same issue you'd run into if unmounting any other filesystem.
You can use the command lsof to get the process having files open there. This can also be an open terminal where the shell has the current working directory at this location.
 
Old 08-18-2012, 11:42 AM   #7
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,784

Rep: Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214
After some experiments to replicate your results, I think you might just have your mount command backwards. It should be:
Code:
mount -t ecryptfs crypted plain
or in /etc/fstab:
Code:
crypted  plain  ecryptfs  {options}  0 0
You are mounting an encrypted "device" onto the (empty) plaintext directory, not the other way around.
The only way I could duplicate the "I/O error" behavior was by reversing the two mount arguments and thus writing plaintext data directly into the supposedly encrypted device.

Examples in documentation seem, for the most part, to show "overlay" mounts, where the two arguments are the same, making it a bit hard to see just what is going on.
 
  


Reply



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] photorec + .ecryptfs to restore files jamendo10 Linux - Security 4 08-07-2012 06:24 AM
rsync copying everything not only changed files with luks encrypted drive changcheh Linux - General 1 09-10-2011 09:44 PM
[SOLVED] Copying the files inside a folder, without copying the folder (hopefully easy) tibberous Linux - Software 3 12-23-2010 01:50 AM
[ECRYPTFS] ecryptfs_init_miscdev: Error whilst attempting to open [/dev/ecryptfs] nitinarora Linux - Kernel 0 03-22-2010 05:36 AM
Permissions error while copying files on NFS, but only on some files caggles Linux - Networking 1 07-30-2009 03:17 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 12:03 PM.

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