LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 01-07-2010, 04:52 AM   #16
arashi256
Member
 
Registered: Jan 2008
Location: Brighton, UK
Distribution: Ubuntu 12.04 / CentOS 6.5
Posts: 385

Original Poster
Rep: Reputation: 61

Quote:
Originally Posted by devnull10 View Post
You could try creating a new home directory when logged in as root for the user jon. The following command will modify the user to have the home directory /home/jon_home (it will be created if it doesn't already exist). The -m flag will copy the contents of your existing home into the new directory.

Code:
usermod -d /home/jon_home -m
I ran: -

Code:
usermod -d /home/jon_home -m jon
but when logging in as "jon", I still get the same error: -

Code:
login as: jon
jon@[machine]'s password:
Last login: Thu Jan  7 10:49:57 2010 from [Some IP]
Could not chdir to home directory /home/jon_home: Permission denied
[jon@joshua11 /]$
Have I done this right?
 
Old 01-07-2010, 05:49 AM   #17
arashi256
Member
 
Registered: Jan 2008
Location: Brighton, UK
Distribution: Ubuntu 12.04 / CentOS 6.5
Posts: 385

Original Poster
Rep: Reputation: 61
Gah, fixed it by shunting everything to another directory, deleting the user and recreating it and shunting everything back. It's fixed it, but I'd prefer to know why it happened in the first place...thanks anyway everyone for all your help.
 
Old 01-07-2010, 05:53 AM   #18
cardy
Member
 
Registered: Jan 2005
Location: Shropshire, England, UK
Distribution: RedHat, Fedora, CentOS..........
Posts: 121

Rep: Reputation: 19
This could be selinux related, there is a quick way to check by switching selinux into permissive mode rather than enforcing.

if you edit the file

/etc/sysconfig/selinux

Quote:
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=enforcing
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
# SETLOCALDEFS= Check local definition changes
SETLOCALDEFS=0
You should have a similar setup to above. If the SELINUX= entry is set to enforcing then selinux is enabled.
If you change this to SELINUX=permissive save the file and reboot the machine then selinux will change to warning you about policy issues rather than enforcing the security.

Assuming after the reboot you can login without error then you can further diagnose the correct permissions that should be applied on the /home directory.

If you still receive the errors even with selinux in permissive mode then its unlikely to be an selinux issue. You can easily change back to your default setting after performing the test by switching back to enforcing in the same file and again rebooting.

Regards

Lee

Last edited by cardy; 01-07-2010 at 05:54 AM.
 
Old 01-07-2010, 05:55 AM   #19
arashi256
Member
 
Registered: Jan 2008
Location: Brighton, UK
Distribution: Ubuntu 12.04 / CentOS 6.5
Posts: 385

Original Poster
Rep: Reputation: 61
Thanks, I'll look into that. I'm thinking more and more that this was an SELinux issue - it was/is certainly enabled on both machines.
 
Old 01-07-2010, 05:57 AM   #20
cardy
Member
 
Registered: Jan 2005
Location: Shropshire, England, UK
Distribution: RedHat, Fedora, CentOS..........
Posts: 121

Rep: Reputation: 19
Just out of interest what permissions are now shown when you run the commands

ls --context /home
ls --context /home/jon


Regards

lee
 
Old 01-07-2010, 06:02 AM   #21
arashi256
Member
 
Registered: Jan 2008
Location: Brighton, UK
Distribution: Ubuntu 12.04 / CentOS 6.5
Posts: 385

Original Poster
Rep: Reputation: 61
Quote:
Originally Posted by cardy View Post
Just out of interest what permissions are now shown when you run the commands

ls --context /home
ls --context /home/jon


Regards

lee
Hi Lee,

Sure thing...

Code:
[root@joshua11 ~]# ls --context /home
drwx------. jon    jon    unconfined_u:object_r:user_home_dir_t:s0 jon
drwx------. root   root   system_u:object_r:file_t:s0      lost+found
[root@joshua11 ~]#
and...

Code:
[root@joshua11 ~]# ls --context /home/jon
drwxrwxr-x. jon jon unconfined_u:object_r:user_home_t:s0 Backup
drwxrwxr-x. jon jon unconfined_u:object_r:user_home_t:s0 Documents
drwxrwxr-x. jon jon unconfined_u:object_r:user_home_t:s0 Downloads
drwxr-xr-x. jon jon unconfined_u:object_r:user_home_t:s0 Music
drwxr-xr-x. jon jon unconfined_u:object_r:user_home_t:s0 Pictures
drwxrwxr-x. jon jon unconfined_u:object_r:file_t:s0  Platforms
drwxrwxr-x. jon jon unconfined_u:object_r:user_home_t:s0 Programs
drwxr-xr-x. jon jon unconfined_u:object_r:user_home_t:s0 RHCT
drwxrwxr-x. jon jon unconfined_u:object_r:user_home_t:s0 SCJP
drwxrwxr-x. jon jon unconfined_u:object_r:file_t:s0  Torrent-Files
[root@joshua11 ~]#
Looks the same to me, but if you want to make an educated guess, go for it
 
Old 06-20-2010, 11:59 PM   #22
billcheng
LQ Newbie
 
Registered: Jun 2010
Location: Los Angeles, California, USA
Distribution: Fedora
Posts: 1

Rep: Reputation: 0
I just want to mention that I have *exactly* the same problem!

My usual setup is that I have a system partition and a user partition. Every time I upgrade, I just reformat the system partition and install the new system on it. Then I do "groupadd" and "user add" to add myself to the system with the home directory set to my directory in the user partition.

I've been using Fedora and this procedure worked till FC8. The next system reinstall I tried after FC8 was FC11 and that's when I started to see this problem and I went back to FC8.

Last week, my machine died. Luckily, my harddrive was fine and I have another machine that I can use. So, I move my harddrive from the dead machine to the other machine and installed FC13. I see exactly the same problem again! When I logged in, I get the error message and my current working directory is set to / and my login scripts in my user partition are not executed.

Then I started googling this problem and found this thread. I just tried setting SELINUX=permissive and rebooted my machine and, Voila, everything is working! Thanks so much!
--
Bill Cheng
 
Old 07-26-2010, 05:34 AM   #23
ASangodkar
LQ Newbie
 
Registered: Jul 2010
Location: Bangalore, India
Distribution: Fedora
Posts: 3

Rep: Reputation: 0
I have also faced the same problem using Fedora 13. I have shared the home directory from an NFS server for all the users in a cluster. Whenever I use SSH to login to a node, it is successful but changing to home directory of the user fails. But when I type cd, it changes to the user's home directory.

Code:
[root@garl-amd1 ~]# ssh akshay@garl-amd5
akshay@garl-amd5's password:
Last login: Mon Jul 26 02:02:38 2010 from garl-amd1
Could not chdir to home directory /home/akshay/: Permission denied
[akshay@garl-amd5 /]$ cd
[akshay@garl-amd5 akshay]$
As suggested by cardy, I tried switching selinux into permissive mode and it worked. How do I get rid of this problem without changing selinux mode?

Akshay
 
Old 07-27-2010, 02:02 AM   #24
ASangodkar
LQ Newbie
 
Registered: Jul 2010
Location: Bangalore, India
Distribution: Fedora
Posts: 3

Rep: Reputation: 0
I have fixed it! It was an SELinux problem. I got an alert from the SELinux troubleshooter after I switched SELinux to permissive mode. It suggested that I should use the command

$setsebool -P use_nfs_home_dirs=1

But, I used the SELinux GUI instead. I guess other related problems can be fixed by configuring SELinux properly.
 
Old 08-26-2010, 06:21 AM   #25
marcoecc
LQ Newbie
 
Registered: Aug 2010
Posts: 1

Rep: Reputation: 0
Talking SElinux

Quote:
Originally Posted by ongte View Post
Very odd looking problem you have there. Could it be a SELinux context issue?
Try looking at the output of these:
# ls --context /home
# ls --context /home/jon

If not SELinux, it could also be an ACL issue. Try:
# getfacl /home


I had the same problem. On one of my hosts I kept receiving this error:
Could not chdir to home directory /home/me: Permission denied
upon login. After logging in, I could just chdir manually into it.

This error in turn also prevented SSH from using key authentication, as the .ssh directory was unreachable before logging in, and SSH defaulted to requesting the password.

After painstakingly checking all the many usual things with SSH on both sides, I checked the SElinux contexts:

on the well-behaving hosts:
# ls --context -d /home /home/me

drwxr-xr-x. root root system_ubject_r:home_root_t:s0 /home
drwx------. me me unconfined_ubject_r:user_home_dir_t:s0 /home/me

on the misbehaved host:
# ls --context -d /home /home/me

drwxr-xr-x. root root system_ubject_r:file_t:s0 /home
drwx------. me me unconfined_ubject_r:user_home_dir_t:s0 /home/me

Notice the /home/me has the same context, while /home hasn't, having file_t instead of home_root_t.

Simply running
# restorecon /home
solved a problem which had taken a few hours to figure out.
 
Old 11-11-2011, 09:29 AM   #26
kevindo2020
LQ Newbie
 
Registered: Jun 2010
Posts: 2

Rep: Reputation: 1
Thank you marcoecc!

I just installed CentOS 6. First time around, I installed the OS on the first drive. Then I added a larger RAID1 partition and copied content of /home into the new RAID1 partition and mounted on /home. Then I got this same problem.

After googling around I finally got to your post.

# restorecon /home
does the trick.

Thanks.
 
  


Reply

Tags
context, directory, home, selinux


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ssh could not chdir to home directory pccdrussell Linux - General 27 08-24-2012 10:30 AM
NFS problem: "Could not chdir to home directory /home/USER: Permission denied" sumanc Linux - Server 4 07-22-2010 04:12 PM
Crontab permission denied while making a directory in user's home Dfangs Linux - Server 3 05-29-2009 09:44 AM
How can I set the permission on the home directory when creating an user crisostomo_enrico Solaris / OpenSolaris 4 09-26-2007 06:24 PM
permission denied to home directory ekdya Debian 3 11-08-2005 04:24 PM


All times are GMT -5. The time now is 05:15 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration