我已经安装了 Fedora,但使用了/home
之前安装的 Ubuntu 中的现有分区:
- 分区:
/boot/efi
,/
(在安装过程中格式化),/home
(从 Ubuntu 中保留),
- 用户的用户名和密码与我在 Ubuntu 安装时使用的用户名和密码相同。
安装后,我无法登录。所以,我安装了软件包ecryptfs-simple.x86_64
和ecryptfs-utils.x86_64
.
要成功登录已安装的/home/<username>
我必须:
- 登录终端,
- 跑步
ecryptfs-mount-private
, - 通过gdm登录。
直接登录gdm
失败。
如何让登录时gdm
自动运行?ecryptfs-mount-private
答案1
这是 SELinux 问题。我通过为 home 和 ecryptfs 的东西设置适当的安全上下文来解决这个问题。使用已卸载的 ecryptfs home 运行此命令:
chcon -u unconfined_u -t user_home_dir_t /home/<username>/
chcon -u unconfined_u -t ecryptfs_t /home/.ecryptfs/<username>/.ecryptfs/
chcon -u unconfined_u -t ecryptfs_t /home/.ecryptfs/<username>/.ecryptfs/*
chcon -h -u unconfined_u -t user_home_t /home/<username>/* /home/<username>/.*
chcon -h -u unconfined_u -t ecryptfs_t /home/<username>/.ecryptfs /home/<username>/.Private
我之前也做过其他实验,可能会有一些效果:
- 在 SELinux 中启用
ecryptfs
家庭加密:setsebool -P useecryptfshome_dirs 1
- 配置 pam 使用 ecryptfs:
- 设置
USEECRYPTFS=yes
在/etc/sysconfig/authconfig
- 再生的
authconfig --enableecryptfs --updateall
- 设置
查看grep ecrypt /etc/pam.d/*
:
/etc/pam.d/postlogin:auth optional pam_ecryptfs.so unwrap
/etc/pam.d/postlogin:password optional pam_ecryptfs.so unwrap
/etc/pam.d/postlogin:session optional pam_ecryptfs.so unwrap
/etc/pam.d/postlogin-ac:auth optional pam_ecryptfs.so unwrap
/etc/pam.d/postlogin-ac:password optional pam_ecryptfs.so unwrap
/etc/pam.d/postlogin-ac:session optional pam_ecryptfs.so unwrap
我希望我没有错过答案中的任何内容。
答案2
在 Fedora 27 上测试的设置:
1. Find out the UUID of the home partition you're trying to mount: blkid
2. edit /etc/crypttab and add the following line:
my-encrypted-home UUID="<UUID-from-above-command>" none luks
3. edit /etc/fstab and comment out the previous home entry and add the following:
/dev/mapper/my-encrypted-home /home ext4 defaults 1 2
重启,小心。普利茅斯将提示您输入密码。如果您在启动时卡住,请重新启动并编辑 grub 条目以禁用 Plymouth(启动画面,可用说明)这里)并等待systemd服务文件失败的超时时间(1分30秒)。系统将提示您以 root 身份登录进入恢复模式。修复错误并重新启动。