LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-03-2008, 03:48 PM   #1
d0127810
LQ Newbie
 
Registered: May 2005
Posts: 27

Rep: Reputation: 15
Debian Chroot help


Sorry to say I'm a bit of a noob (but we all gotta start somewhere I guess) - I'm trying to setup a jail for my SSH users on my debain etch server.

I've tried using the libpam-chroot it has a quite simple README file - I think I have followed it to a T but clearly there something gone wrong.

I checked the auth.log :

Aug 3 19:25:46 localhost sshd[19404]: (pam_unix) session opened for user bob by (uid=0)
Aug 3 19:25:46 localhost PAM-env[19404]: Unable to open config file: No such file or directory

I think it something to do with point 1 the
chrooted-directory-tree.txt file - I haven't put it anywhere the where the ssh can see it when the user logs in. The readme doesn't suggest anywhere.

Any help would greatly be appreciated - I can't see anything relevant in the syslog (or at least anything with PAM or bob the user on it).

Thanks

Dan



======= The README that I followed =======================

This is a sample configuration for the pam_chroot module.

In order to make this work you need to:

1.- use setup-chrootdir.sh to create a directory in which
the user will be chrooted (let's call it CHROOTDIR)
A sample layout like the one it creates is provided in the
chrooted-directory-tree.txt file

WARNING! Make sure to have an open console in which to
become superuser in case you mangle the files and cannot
log-on to the system later on!

2.- configure /etc/security/chroot.conf so that a given user
(USERCHROOTED) is chrooted to CHROOTDIR when entering (in the
sample configuration file CHROOTDIR=/chroot/directory)

3.- add the following line to /etc/pam.d/login
session required pam_chroot.so debug

4.- create USERCHROOTED in the system (/etc/passwd et al.) and
have his home directory be /home/test
(real directory=CHROOTDIR/home/test)

5.- add the neccesary .profile, .cshrc, .bash_profile files to
the CHROOTDIR/home/test directory (fix permissions to your own
needs/policy)

6.- Try to enter the system as USERCHROOTED. You should be
restricted to CHROOTDIR and have only a limited number of
utilies (setup-chrootdir only provides 'ls')

If it does not work check the syslog files to see the messages
related to PAM (should include pam_chroot[XXXX]: session messages
due to the 'debug' option being set)
 
Old 08-03-2008, 06:34 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Are you sure you want to use pam_chroot for that? Chroot functionality was recently added to OpenSSH itself. If you want to proceed, which version of pam_chroot are you using and did you read the troubleshooting doc (syslog socket)? Which PAM configs did you add pam_chroot to? What does it or what do they look like?
 
Old 08-04-2008, 03:30 AM   #3
d0127810
LQ Newbie
 
Registered: May 2005
Posts: 27

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by unSpawn View Post
Are you sure you want to use pam_chroot for that? Chroot functionality was recently added to OpenSSH itself. If you want to proceed, which version of pam_chroot are you using and did you read the troubleshooting doc (syslog socket)? Which PAM configs did you add pam_chroot to? What does it or what do they look like?
To be honest I just want the jail facility if this is in OpenSSH itself then I would be more than happy to use that. Are there any good HOWTOs you can suggest?
 
Old 08-04-2008, 05:20 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
How about perusing the OpenSSH docs? ;-p
 
Old 08-04-2008, 07:26 AM   #5
d0127810
LQ Newbie
 
Registered: May 2005
Posts: 27

Original Poster
Rep: Reputation: 15
Had a look around but can't find anything on the openssh website:

http://www.openssh.com

Little help with direction please
 
Old 08-04-2008, 08:17 AM   #6
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
If you look in the openssh-5.1p1 package (or earlier, it was added to 4.8 I think) at the manual pages for sshd_config you'll see some references:
Quote:
Originally Posted by man ./sshd_config.5
ChrootDirectory
Specifies a path to chroot(2) to after authentication. This path, and all its components, must be root-owned directories that are not writable by any other user or group. The path may contain the following tokens that are expanded at runtime once the connecting user has been authenticated: %% is replaced by a literal ’%’, %h is replaced by the home directory of the user being authenticated, and %u is replaced by the username of that user.

The ChrootDirectory must contain the necessary files and directories to support the users’ session. For an interactive session this requires at least a shell, typically sh(1), and basic /dev nodes such as null(4), zero(4), stdin(4), stdout(4), stderr(4), arandom(4) and tty(4) devices. For file transfer sessions using “sftp”, no additional configuration of the environment is necessary if the in-process sftp server is used (see Subsystem for details).
On the other hand, if you want to proceed with pam_chroot, which version are you using and did you read the troubleshooting doc (syslog socket)? Which PAM configs did you add pam_chroot to? What does it or what do they look like?
 
Old 08-04-2008, 09:40 AM   #7
d0127810
LQ Newbie
 
Registered: May 2005
Posts: 27

Original Poster
Rep: Reputation: 15
version:
libpam-chroot (0.9-1)

Added the following line to /etc/pam.d/ssh:

session required pam_chroot.so debug

And I think it's suppose to output to the syslog under /var/log which looks like

Aug 4 15:31:20 localhost afpd[3270]: uam: loading (/usr/lib/netatalk/uams_dhx.so)
Aug 4 15:31:20 localhost afpd[3270]: uam: uam not found (status=-1)
Aug 4 15:31:20 localhost afpd[3270]: uam: loading (/usr/lib/netatalk/uams_clrtxt.so)
Aug 4 15:31:20 localhost afpd[3270]: uam: uams_clrtxt.so loaded
Aug 4 15:31:20 localhost afpd[3270]: uam: loading (/usr/lib/netatalk/uams_randnum.so)
Aug 4 15:31:20 localhost afpd[3270]: uam: uam not found (status=-1)
Aug 4 15:31:20 localhost afpd[3270]: uam: "Cleartxt Passwrd" available
Aug 4 15:33:01 localhost /USR/SBIN/CRON[3577]: (nobody) CMD ([ -x /usr/share/sa-exim/greylistclean ] && /usr/share/sa-exim/greylistclean)
Aug 4 15:33:01 localhost sa-exim[3578]: Removed 0 of 0 greylist tuplets in 0 seconds
Aug 4 15:33:01 localhost sa-exim[3578]: Removed 0 of 0 greylist directories in 0 seconds
Aug 4 15:35:29 localhost dhclient: DHCPDISCOVER on eth1 to 255.255.255.255 port 67 interval 8
Aug 4 15:35:37 localhost dhclient: DHCPDISCOVER on eth1 to 255.255.255.255 port 67 interval 15
Aug 4 15:35:52 localhost dhclient: DHCPDISCOVER on eth1 to 255.255.255.255 port 67 interval 19
 
Old 08-04-2008, 11:20 AM   #8
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Your "localhost PAM-env[19404]: Unable to open config file: No such file or directory" line points to it looking for CHROOTDIR/etc/security/ and CHROOTDIR/etc/environment where your pam_env stuff is. If you don't see any logging inside your chroot, mkdir CHROOTDIR/dev/ and restart Syslogd with "-a CHROOTDIR/dev/log". Wrt PAM and SSH the pam_chroot docs specifically points to "ChallengeResponseAuthentication" and "UsePAM" sshd_config options. Please read that again?
 
Old 08-04-2008, 11:45 AM   #9
d0127810
LQ Newbie
 
Registered: May 2005
Posts: 27

Original Poster
Rep: Reputation: 15
Thanks I will try that and get back to you.

Thanks alot UnSpawn
 
Old 08-05-2008, 04:32 AM   #10
d0127810
LQ Newbie
 
Registered: May 2005
Posts: 27

Original Poster
Rep: Reputation: 15
First off I apologise I didn't read through the entire document plus I used the readme which clearly was inadequete in covering all areas of the chroot process.

After going through the doc I found

debootstrap sid /sid-root http://ftp.debian.org/debian/

which I setup on the bob user and used the appropriate directory.

I seems to have installed a version of the debian - which might have been a little overkill but the environment now works just fine.

What can I cut out to make it a lighter environment?

Thanks

Dan

Last edited by d0127810; 08-05-2008 at 04:34 AM.
 
Old 08-05-2008, 06:28 AM   #11
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
No need to apologise, after all it's *you* who has been doing all the work :-] To cut out stuff you first want a list of packages: chroot into your chroot, run 'dpkg -l' (or 'dpkg -l | grep ^i' for only installed packages?), output to a file, edit out those you know you need, then post the list of packages you're unsure about. Wrt removal it would also be good to know what you want to do with this chroot (reason).
 
Old 08-05-2008, 08:41 AM   #12
d0127810
LQ Newbie
 
Registered: May 2005
Posts: 27

Original Poster
Rep: Reputation: 15
The aim would be to have a bare basics chroot environment so applications can SSH to the server and tunnel through to the MySQL server. When I did the boot strap it seems to have everything that the main debian server has (folder wise).
 
  


Reply



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
Debian Bind9 chroot problems eentonig Linux - Server 1 09-24-2008 10:39 AM
Debian AMD64 chroot questions Arnaud_B Debian 13 05-05-2007 02:10 PM
debian stuck within 32bit chroot on 64bit sarge linuxmandrake Debian 8 12-13-2005 03:01 PM
chroot ia32 on debian linuxmandrake Debian 3 12-11-2005 03:10 PM
Debian 32bit chroot setup question Oxyacetylene Debian 4 11-28-2005 08:01 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:02 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration