LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   User that can not move from his own home dir (https://www.linuxquestions.org/questions/linux-newbie-8/user-that-can-not-move-from-his-own-home-dir-826268/)

booyeeka 08-14-2010 05:15 PM

User that can not move from his own home dir
 
is it possible to make that user can not move from his own home directory?

thank you in advance!

TB0ne 08-14-2010 05:27 PM

Quote:

Originally Posted by booyeeka (Post 4066483)
is it possible to make that user can not move from his own home directory?

thank you in advance!

Maybe, but you provide no details.

What KIND of user? (console? SSH? Telnet? FTP?). What version/distro of Linux? What you're talking about is "chroot", and can be done for SSH and FTP users. You can probably script something to make sure the user can't change directories above their own home dir, too, depending on what you're talking about.

myposts 08-14-2010 05:29 PM

simply...
 
You modify a shell profile for the user with an alias for cd command that will block/substitute his attempts to move elsewhere. Make the profile file writable to root only, so the user could not overwrite it, yes, don't forget exporting it.

I hope it helps. See "Learn Linux for a Beginner" DVDs by unixacademy.com for questions like that.

booyeeka 08-14-2010 05:31 PM

it's for ssh user.

so, let's call it regular-no-root user, that belongs to some custom group...

jv2112 08-14-2010 07:04 PM

Am I being to simple---->

chmod -R 700 / :study:

TB0ne 08-14-2010 07:41 PM

Quote:

Originally Posted by jv2112 (Post 4066541)
Am I being to simple---->
chmod -R 700 / :study:

Yes...because with those permissions, no one except root could get to the /etc directory, to read default profile information, password/shadow files, etc. They'd also be unable to start a shell, since they're in /bin/bash, which would be excluded from the path by those permissions, not to mention all the applications you'd break by doing that recursively from root.

Quote:

Originally Posted by myposts
You modify a shell profile for the user with an alias for cd command that will block/substitute his attempts to move elsewhere.

..except that the user will then be unable to change directories WITHIN his own home directory.

Quote:

Originally Posted by booyeeka
it's for ssh user.
so, let's call it regular-no-root user, that belongs to some custom group...

You STILL say nothing about version/distro of Linux. Read my first post again, about SSH supporting chroot'ed users. It effectively making their own home directories look like the "/" directory. Since they're already effectively at top-level, they obviously can't go up, or anywhere else, if they're chroot'ed. Since you don't give any details about version/distro of Linux, go to Google and look up "linux chroot ssh" for your version. Follow the instructions.

booyeeka 08-15-2010 01:52 AM

it's fedora distro. but i don't know why it's distro-related...

btmiller 08-15-2010 02:03 AM

You do realize you'll need to put copies of all the required binaries and libraries into the chroot'ed environment, right? Nine times out of ten when I see someone doing this they're going on a roundabout way to solve some particular problem. What exactly are you trying to accomplish by limiting a user to his home directory? On a well-secured system it's generally not a problem to let the user traverse the file system unless you have some very special requirements.

In any case look into chrooting ssh ... if you Google there are a number of guides on how to do it. You can also put bash into restricted mode which will let the user access needed binaries and libraries, but won't let them change directories at all IIRC so they're stuck in their home directory. Depending on your exact requirements, this may be good enough.

TB0ne 08-15-2010 12:11 PM

Quote:

Originally Posted by booyeeka (Post 4066684)
it's fedora distro. but i don't know why it's distro-related...

First, it's common courtesy to supply details when asking a question.

Second, as said before, the instructions/packages for setting up chroot'ed SSH vary by distro. So what works on Ubuntu, won't necessarily work on Fedora, that's why.


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