UBUNTU使用日记

关于Ubuntu的故事或对Ubuntu的感慨及心情
回复
头像
marklennon
帖子: 267
注册时间: 2011-02-23 13:43
系统: UBUNTU 12.04
联系:

Re: UBUNTU使用日记

#76

帖子 marklennon » 2014-06-21 11:51

恢复被ecryptfs加密的主目录

2010-12-19 16:26:59| 分类: Linux |举报|字号 订阅
很不幸, 前两天系统被我弄得启动不了了。更不幸的是我先择了加密我的主目录选项。简单的说就是把整个主目录都加密了,如果电脑丢失或者重新安装系统时,没有关键密码此主目录则永远无法恢复,数据则可保无忧。不管有没有用,用各种方法试验恢复主目录时总是遇到各种各样的问题,其中最好的情况是目录恢复了,但其中的文件名称是乱码,根本无法解读,在网上找了很久的资料,最后才发现原因,贴在此处:

可以用live CD启动,登入系统后要做的第一件事情就是保存好密钥,在终端中输入:

ecryptfs-unwrap-passphrase

则可以得到一串长长的字符串,保存在安全的地方,这是关键;
仔细检查安装的系统,你会发现,被加密的整个主目录实际上只是一个被挂载的空目录,里面只有四个文件,真正的文件实际上存放在 /home/.ecryptfs/你的主目录名/.Private中,是加密存放的,所以重新安装系统时,这个目录一定不能被删除,否则神仙也救不了你。

假设已经重新安装了系统,则进行如下操作:
确认先前的/home/.ecryptfs/被加密的目录名/.Private 里面的文件在不在,如果不在,不用继续了
如果先前忘记保存的密钥串或者密钥串丢了,检查
/home/.ecryptfs/被加密的目录名/.ecryptfs/wrapped-passphrase文件在不在,如果不在,也不用继续了,如果在,
安装ecryptfs:
sudo aptutide install ecryptfs-utils
如果已经安装,此步略。
在终端中输入:
sudo ecryptfs-unwrap-passphrase wrapped-passphrase 不用说在哪运行了吧,就是在旧的那个wrapped-passphrase文件所在的目录里,你想将这个文件拷贝出来操作也随便你
Passphrase: 输入以前主目录被加密的用户密码
得到密钥串,保存起来
在现在的主目录下新建一个目录restore
在终端输入:
sudo ecryptfs-add-passphrase –fnek 注:–fnek 有两个 -,即“- -fnek”,还有,如果这一步不sudo,同样会出错
Passphrase:输入先前保存在安全位置的那一长串字符串
Inserted auth tok with sig [6ceb75c6208b3c78] into the user session keyring
Inserted auth tok with sig [01bda2c2fc25d863] into the user session keyring
记住方括号中的两串字符串,后面要用到。其中第二串是解密文件名用的
注:这一步相当重要,很多时候就是因为这一步没有做,没有将先前保存的密钥导入密钥环中(我是这么理解的),结果要不恢复出错,要不恢复出来的文件名称、目录名称全部是看不懂的东东。在终端输入:
sudo mount -t ecryptfs /home/.ecryptfs/以前那个被加密主目录名称/.Private ~/restore
Passphrase:同样输入先前保存的字符串
Select cipher:
1) aes: blocksize = 16; min keysize = 16; max keysize = 32 (not loaded)
2) blowfish: blocksize = 16; min keysize = 16; max keysize = 32 (not loaded)
3) des3_ede: blocksize = 8; min keysize = 24; max keysize = 24 (not loaded)
4) twofish: blocksize = 16; min keysize = 16; max keysize = 32 (not loaded)
5) cast6: blocksize = 16; min keysize = 16; max keysize = 32 (not loaded)
6) cast5: blocksize = 8; min keysize = 5; max keysize = 16 (not loaded)
Selection [aes]:直接回车
Select key bytes:
1) 16
2) 32
3) 24
Selection [16]:直接回车
Enable plaintext passthrough (y/n) [n]:直接回车
Enable filename encryption (y/n) [n]: y 这一步很关键,因为加密主目录时文件名称是默认加密的,一定要回答y
Filname Encryption Key (FNEK) Signature [6ceb75c6208b3c78]: 01bda2c2fc25d863 将前面提到的那两串字符串中的第二串输入
Attempting to mount with the following options:
ecryptfs_unlink_sigs
ecryptfs_fnek_sig=01bda2c2fc25d863
ecryptfs_key_bytes=16
ecryptfs_cipher=aes
ecryptfs_sig=6ceb75c6208b3c78
WARNING: Based on the contents of [/root/.ecryptfs/sig-cache.txt],
it looks like you have never mounted with this key
before. This could mean that you have typed your
passphrase wrong.
Would you like to proceed with the mount (yes/no)? yes 你从未用这个密码挂载过,是否继续?
Would you like to append sig [86a764759a1f7625] to
[/root/.ecryptfs/sig-cache.txt]
in order to avoid this warning in the future (yes/no)? no 是否将此次挂载信息记录下来以免下次报警?
Not adding sig to user sig cache file; continuing with mount.

到此,去访问主目录中的restore文件夹,应该不会出现问题了。把要恢复的文件拷贝出来,不然下次开机想再进去又要来一次。如果你没有在最开始那一步进行
ecryptfs-add-passphrase –fnek
的操作的话,应该会出现以下的出错信息:
Error mounting eCryptfs: [-2] No such file or directory
目录挂载失败。莫名其妙。找不到文件?就是这个问题困扰了我很长一段时间,总是挂载失败。
这是比较简单的方式,对于ecryptfs复杂运用,欢迎和我讨论。

代码: 全选

Mark@Mark-pc:~$ cd /home/Mark/restore
Mark@Mark-pc:~/restore$ sudo su
[sudo] password for Mark: 
root@Mark-pc:/home/Mark/restore# ecryptfs-add-passphrase --fnek
Passphrase: 
Inserted auth tok with sig [8336205fa463f0e0] into the user session keyring
Inserted auth tok with sig [74bd6d7908a0fa49] into the user session keyring
root@Mark-pc:/home/Mark/restore# sudo mount -t ecryptfs /home/.ecryptfs/mark/.Private ~/restore
Passphrase: 
Select cipher: 
 1) aes: blocksize = 16; min keysize = 16; max keysize = 32
 2) blowfish: blocksize = 8; min keysize = 16; max keysize = 56
 3) des3_ede: blocksize = 8; min keysize = 24; max keysize = 24
 4) twofish: blocksize = 16; min keysize = 16; max keysize = 32
 5) cast6: blocksize = 16; min keysize = 16; max keysize = 32
 6) cast5: blocksize = 8; min keysize = 5; max keysize = 16
Selection [aes]: 
Select key bytes: 
 1) 16
 2) 32
 3) 24
Selection [16]: 
Enable plaintext passthrough (y/n) [n]: 
Enable filename encryption (y/n) [n]: y
Filename Encryption Key (FNEK) Signature [8336205fa463f0e0]: 74bd6d7908a0fa49
Attempting to mount with the following options:
  ecryptfs_unlink_sigs
  ecryptfs_fnek_sig=74bd6d7908a0fa49
  ecryptfs_key_bytes=16
  ecryptfs_cipher=aes
  ecryptfs_sig=8336205fa463f0e0
Error mounting eCryptfs: [-2] No such file or directory
Check your system logs; visit <http://ecryptfs.org/support.html>
root@Mark-pc:/home/Mark/restore# cd
root@Mark-pc:~# cd /home/.ecryptfs/mark
root@Mark-pc:/home/.ecryptfs/mark# ls
auto-mount   Private.mnt  restore
auto-umount  Private.sig  wrapped-passphrase
root@Mark-pc:/home/.ecryptfs/mark# cd .Private
root@Mark-pc:/home/.ecryptfs/mark/.Private# ecryptfs-add-passphrase --fnek
Passphrase: 
Inserted auth tok with sig [8336205fa463f0e0] into the user session keyring
Inserted auth tok with sig [74bd6d7908a0fa49] into the user session keyring
root@Mark-pc:/home/.ecryptfs/mark/.Private# sudo mount -t ecryptfs /home/.ecryptfs/mark/.Private /home/Mark/restore
Passphrase: 
Select cipher: 
 1) aes: blocksize = 16; min keysize = 16; max keysize = 32
 2) blowfish: blocksize = 8; min keysize = 16; max keysize = 56
 3) des3_ede: blocksize = 8; min keysize = 24; max keysize = 24
 4) twofish: blocksize = 16; min keysize = 16; max keysize = 32
 5) cast6: blocksize = 16; min keysize = 16; max keysize = 32
 6) cast5: blocksize = 8; min keysize = 5; max keysize = 16
Selection [aes]: 
Select key bytes: 
 1) 16
 2) 32
 3) 24
Selection [16]: 
Enable plaintext passthrough (y/n) [n]: 
Enable filename encryption (y/n) [n]: y
Filename Encryption Key (FNEK) Signature [8336205fa463f0e0]: 74bd6d7908a0fa49
Attempting to mount with the following options:
  ecryptfs_unlink_sigs
  ecryptfs_fnek_sig=74bd6d7908a0fa49
  ecryptfs_key_bytes=16
  ecryptfs_cipher=aes
  ecryptfs_sig=8336205fa463f0e0
Mounted eCryptfs
root@Mark-pc:/home/.ecryptfs/mark/.Private# 
root@Mark-pc:/home/.ecryptfs/mark/.Private# 

代码: 全选

74bd6d7908a0fa49

bdd37c2f5c7efbc11f3fa01b00bc47bdcd
bdd37c2f5c7efbc11f3fa01b00bc47bd

sudo ecryptfs-add-passphrase --fnek

sudo mount -t ecryptfs /home/.ecryptfs/mark/.Private ~/restore
No Way to Go....
头像
marklennon
帖子: 267
注册时间: 2011-02-23 13:43
系统: UBUNTU 12.04
联系:

Re: UBUNTU使用日记

#77

帖子 marklennon » 2014-06-21 14:56

代码: 全选

Mark@Mark-pc:~$ virtualbox 
WARNING: The character device /dev/vboxdrv does not exist.
	 Please install the virtualbox-dkms package and the appropriate
	 headers, most likely linux-headers-generic.

代码: 全选

$ su
# modprobe vboxdrv
No Way to Go....
头像
marklennon
帖子: 267
注册时间: 2011-02-23 13:43
系统: UBUNTU 12.04
联系:

Re: UBUNTU使用日记

#78

帖子 marklennon » 2014-06-23 12:16

中文本地化后 会安装2个字体
fonts-arphic-ukai
fonts-arphic-uming


找到这两个字体删除之。。。

代码: 全选

sudo apt-get remove fonts-arphic-ukai fonts-arphic-uming
No Way to Go....
头像
marklennon
帖子: 267
注册时间: 2011-02-23 13:43
系统: UBUNTU 12.04
联系:

Re: UBUNTU使用日记

#79

帖子 marklennon » 2014-06-24 15:11

No Way to Go....
头像
marklennon
帖子: 267
注册时间: 2011-02-23 13:43
系统: UBUNTU 12.04
联系:

Re: UBUNTU使用日记

#80

帖子 marklennon » 2014-09-23 12:19

No Way to Go....
头像
marklennon
帖子: 267
注册时间: 2011-02-23 13:43
系统: UBUNTU 12.04
联系:

Re: UBUNTU使用日记