我在跟踪 Wheezy/Sid 的 Linux Mint Debian Edition 上运行 lxc。我使用“lxc-create -t debian -n dev”创建了一个容器。根据 Debian wiki 上关于 LXC 的文章,我已将 cgroups 文件系统安装为 /cgroup,并将“cgroup_enable=memory”添加到“GRUB_CMDLINE_LINUX_DEFAULT”设置以启用 cgroup 内存控制(不确定这是否仍然需要,但应该不会有什么坏处,我正在运行内核 3.2.0-1-amd64)。
启动容器后,我添加了一个用户,一切似乎都很好。如果我尝试使用新用户登录系统,我会得到以下信息:
# ssh dev@dev
dev@dev's password:
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Wed Feb 1 07:37:28 2012 from lxc-host
Could not chdir to home directory /home/dev: Permission denied
/bin/bash: Permission denied
Connection to dev closed.
在系统内部以 root 用户身份使用 su 会产生以下结果:
root@dev:~# su -c bash dev
su: User not known to the underlying authentication module
我需要做什么才能以该用户身份登录?
顺便说一句,这里是 /home 的 ls,显示该目录确实存在:
root@dev:~# ls -al /home/dev
total 12
drwxr-xr-x 1 dev dev 54 Feb 1 07:33 .
drwxr-xr-x 1 root root 6 Feb 1 07:33 ..
-rw-r--r-- 1 dev dev 220 Nov 30 11:01 .bash_logout
-rw-r--r-- 1 dev dev 3085 Nov 30 11:01 .bashrc
-rw-r--r-- 1 dev dev 675 Nov 30 11:01 .profile
此外,这里是 ssh 尝试和随后的 su 尝试的相关 auth.log 条目:
Feb 1 19:15:44 dev sshd[3599]: Accepted password for dev from 192.168.254.1 por
t 43667 ssh2
Feb 1 19:15:44 dev sshd[3599]: pam_unix(sshd:session): session opened for user
dev by (uid=0)
Feb 1 19:15:44 dev sshd[3601]: Received disconnect from 192.168.254.1: 11: disc
onnected by user
Feb 1 19:15:44 dev sshd[3599]: pam_unix(sshd:session): session closed for user
dev
...
Feb 1 19:17:19 dev su[3606]: Successful su for dev by root
Feb 1 19:17:19 dev su[3606]: + /dev/pts/0 root:dev
Feb 1 19:17:19 dev su[3606]: pam_unix(su:session): session opened for user dev
by root(uid=0)