SL6:非标准主目录,错误:登录时无法 chdir 到主目录,但 cd $HOME 有效?

Ste*_*ski 4 rhel6 scientific-linux

我有一个全新的 Scientific Linux 6 实例(类似于 RHEL6 和 CentOS6),在 Parallels 上运行。

主目录位于非标准位置,我将其称为 /homedir

当我 ssh 进入这个框时,我收到一个错误:

laptop $ ssh 192.168.1.100
stefanl@192.168.1.100's password: 
Could not chdir to home directory /homedir/stefanl: Permission denied
Run Code Online (Sandbox Code Playgroud)

但紧接着我就可以 chdir 到那个目录,没有错误:

[stefanl@localhost /]$ cd /homedir/stefanl
[stefanl@localhost ~]$ touch foo
[stefanl@localhost ~]$ ls -la
total 28
drwx------. 3 stefanl wheel   4096 Sep 14 17:53 .
drwxr-xr-x. 5 root    root    4096 Sep 14 17:16 ..
-rw-------. 1 stefanl stefanl  303 Sep 14 18:16 .bash_history
-rw-r--r--. 1 stefanl stefanl   18 May 26 08:46 .bash_logout
-rw-r--r--. 1 stefanl stefanl  176 May 26 08:46 .bash_profile
-rw-r--r--. 1 stefanl stefanl  124 May 26 08:46 .bashrc
-rw-rw-r--. 1 stefanl stefanl    0 Sep 14 17:46 foo
Run Code Online (Sandbox Code Playgroud)

此外,作为 root 我可以su使用我的帐户,它似乎工作正常。如果我没有 chdir 到这个目录的权限,我希望看到一个错误。

[stefanl@localhost ~]$ pwd
/data/homedir/stefanl
[stefanl@localhost ~]$ touch bar
[stefanl@localhost ~]$ 
Run Code Online (Sandbox Code Playgroud)

为什么我在初始登录时出错,但之后我可以cd立即进入同一个目录?

Tom*_*haw 5

这可能是 SELinux 问题。检查/var/log/audit/audit.log任何相关消息。请参阅此信息性帖子以获取更多信息,包括可能的修复:

# chcon -t home_root_t /homedir/stefanl
Run Code Online (Sandbox Code Playgroud)