4

I have a brand new Scientific Linux 6 instance (Similar to RHEL6 & CentOS6), running on Parallels.

The home directory is in a non-standard location, which I'll call /homedir

When I ssh into this box I get an error:

laptop $ ssh 192.168.1.100
stefanl@192.168.1.100's password: 
Could not chdir to home directory /homedir/stefanl: Permission denied

But then immediately afterwards I can chdir to that directory, without an error:

[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

In addition, as root I can su to my account and it seems to work fine. If I didn't have permission to chdir to this directory, I would expect to see an error.

[stefanl@localhost ~]$ pwd
/data/homedir/stefanl
[stefanl@localhost ~]$ touch bar
[stefanl@localhost ~]$ 

Why do I get an error during the initial login, but then I can cd to that same directory immediately afterwards?

Stefan Lasiewski
  • 22,949
  • 38
  • 129
  • 184

2 Answers2

5

It could be an SELinux issue. Check /var/log/audit/audit.log for any related messages. See this informative post for more information, including a possible fix:

# chcon -t home_root_t /homedir/stefanl
Tom Shaw
  • 3,702
  • 15
  • 23
  • That certainly looks like my problem. But I don't see this error in audit.log (but that log is hard to comprehend). I thought that selinux was disabled on this box. – Stefan Lasiewski Sep 15 '11 at 16:28
  • 1
    Ah yes, this issue is triggered by selinux. `/etc/sysconfig/selinux` had `SELINUX=enforcing`, and I changed this to `SELINUX=permissive`, then rebooted this host. – Stefan Lasiewski Sep 15 '11 at 16:31
2

The correct command without setting SELinux to permissive is: #chcon -t home_root_t /homedir (note the missing stefanl directory)

dandfra
  • 21
  • 1