LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Could not chdir to home directory; permission denied (https://www.linuxquestions.org/questions/linux-newbie-8/could-not-chdir-to-home-directory%3B-permission-denied-4175425346/)

dmz1213 09-03-2012 12:03 AM

Could not chdir to home directory; permission denied
 
Hello:
An user id u01 on a CentOS 6 server fv18:
u01:x:501:501:user 01:/sahome/u01:/bin/bash
From a remote server, ssh to it:
$ ssh -l u01 fv18
u01@fv18's password:*****
Could not chdir to home directory /sahome/u01: Permission denied

On server fv18, the home directory /sahome/u01 is:
drwx------. 4 u01 u01 1024 Sep 2 21:40 u01
sahome’s permission is
drwxr-xr-x. 5 root root 1024 Sep 2 21:53 sahome
sahome itself is a logical volume:
LV Name /dev/vg0/sahome
VG Name vg0
LV Write Access read/write
LV Status available
# open 1
LV Size 100.00 MiB
Current LE 25
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:6
Both servers are CentOS 6. On fv18, # su – u01 works fine.
Have a good holiday.
Warren

chrism01 09-03-2012 12:28 AM

Check logs eg /var/log/messages, /var/log/secure.
Also, check /etc/ssh/sshd_config for eg chroot settings

dmz1213 09-03-2012 12:52 AM

Hello:
Update:
ssh actually logs into fv18 as u01. With the chdir error, it puts on "/" instead.
From "/", user u01 can issue command cd to jump to its own home directory...

$ ssh -l u01 fv18
u01@fv18's password:
Last login: Sun Sep 2 22:42:10 2012
Could not chdir to home directory /sahome/u01: Permission denied
[u01@fv18 /]$ pwd
/
[u01@fv18 /]$ cd
[u01@fv18 ~]$ pwd
/sahome/u01

Under u01, manually run
$ . ./.bash_profile
$ . ./.bashrc and
$ . /etc/bashrc all completes without error.

There is no error or warning on /etc/log/messages and /var/log/audit.
Thanks.
Warren

em31amit 09-03-2012 12:59 AM

did you get a chance to check SeLINUX, here ls showing "." at the end of file permission, that means SeLinux is there. if all permission looks good than it is selinux which is preventing to change the directory. you must look into selinux

checkout what /var/log/audit/audit.log says..

chrism01 09-03-2012 04:57 AM

Actually a dot at the end means acls eg getfacl.
You can check SELinux with
Code:

ls -lZ
That would indeed be /var/log/audit, but I asked about /var/log/secure, which is where ssh logs to (or messages if the file does not exist).
Also, as I said, check sshd_config, as this happens (as you have shown) when logging in via ssh.

dmz1213 09-03-2012 01:16 PM

I set SELinux on fv18 to permissive, then ssh to fv18 as u01 works fine without the chdir error.
It appears the file system /sahome has access restrictions. If i change u01's home directory to /home, ssh does not have any issue regardless of SELinux's setting.

Where /home is a sub-directory; /sahome is a file system.

W

dmz1213 09-03-2012 02:02 PM

I define/reset SELinux security context on /sahome.
# restorecon -R -v /sahome
# ls-Zd /sahome
drwxr-xr-x. root root system_u:object_r:home_root_t:s0 /sahome

u01 is able to ssh to fv18 without chdir error.

Thanks.
Warren


All times are GMT -5. The time now is 07:09 PM.