LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Restricting a user to their home directory - not working (https://www.linuxquestions.org/questions/linux-general-1/restricting-a-user-to-their-home-directory-not-working-4175593916/)

Sharkadder 11-30-2016 06:59 PM

Hi there,
Ok i am a slight step further i think. You telling me...SFTP is the vane of my life at the moment as it just won't do what i want to do. I tried making all directories owned by root e.g. /var /var/www /var/www/html and /var/www/html/testyourwebsitenow and i think tried having /var/www/html/ owned by root and /testyourwebsitenow owned by tester which should work in the same way as you said right? I have got a stage further but still cannot access the testyourwebsitenow directory from SFTP with tester

I also read that the root has to be in the tester group too? It's just really confusing as different things i read on the net tell me different stories due to SFTP being so funny.

Here is what i currently have now:
Code:

[root@a000066 var]# ls -ld /var/www
drwxr-sr-x+ 6 root root 4096 Oct 18 09:47 /var/www
[root@a000066 var]# ls -ld /var/www/html/
drwxr-sr-x+ 3 root root 4096 Dec  1 00:12 /var/www/html/
[root@a000066 var]# ls -ld /var/www/html/testyourwebsitenow/
drwxrwsr-x. 8 tester tester 4096 Dec  1 00:12 /var/www/html/testyourwebsitenow/

Now the person can log into filezilla and goes into the /var/www/html directory but when they click on testyourwebsitenow folder it says permission denied.

Password file noq shows this for tester:
tester:x:500:500:Web Tester:/var/www/html/testyourwebsitenow:/sbin/nologin

I then did a
chmod -R 755 /var/www/html/testyourwebsitenow/ (the tester user owns this folder as shown above)

Still cannot access the folder. Any more hints?

c0wb0y 12-02-2016 03:37 PM

SFTP can be the vane of your life. Or it can be the love of your life too. :)
In my opinion, it is never a good idea to assign $HOME to any subdirs under /var or any system dirs for that matter. That is what /home for.

Back to your issue. So your $HOME is assigned to /var/www/html/testyourwebsitenow.
Quote:

Password file noq shows this for tester:
tester:x:500:500:Web Tester:/var/www/html/testyourwebsitenow:/sbin/nologin
And as per your output below:
Quote:

[root@a000066 var]# ls -ld /var/www/html/testyourwebsitenow/
drwxrwsr-x. 8 tester tester 4096 Dec 1 00:12 /var/www/html/testyourwebsitenow/
It is owned by tester:tester, which should be alright IF you're not going to use SFTP. But you want SFTP, so it is not happy about that. The $HOME should be owned by root:root. You then create ANOTHER subfolder beneath it to be owned and writable by tester:tester. You then sftp then cd into that folder. That's why SFTP has a funny way of doing things :) .

Last words:
- don't assign root to any group haphazardly.
- I was wondering what all those SGID bits for?
- logs. Check them. Read them.


All times are GMT -5. The time now is 04:07 AM.