PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > comp.security.ssh > chroot SFTP ONLY
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.security.ssh SSH secure remote login and tunneling tools.

chroot SFTP ONLY

Réponse
 
LinkBack Outils de la discussion
Vieux 07/11/2006, 19h39   #1
mohamed.zubaidi@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut chroot SFTP ONLY

I saw this problem posted on many places with no solution so far.

How can we chroot SFTP but NOT SSH sessions for the same user ?
I know it doesn't make sense but humor me, this is a requirement in
some enterprise environments with many generic apps IDs.

The session.c evaluates the type of connection in the function
session_input_channel_req which is called from serverloop.c by
server_input_channel_req.
However, this is all done way after chroot happens in the
do_setusercontext function.

so I'm trying to find a way to get the same at that level. I just need
a hint which is the first function to differentiate between sftp and
ssh in the openssh code and how to use it in session.c

Any will be much appreciated.

MJ

  Réponse avec citation
Vieux 09/11/2006, 10h16   #2
Steven Mocking
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: chroot SFTP ONLY

mohamed.zubaidi@gmail.com wrote:
> How can we chroot SFTP but NOT SSH sessions for the same user ?
> I know it doesn't make sense but humor me, this is a requirement in
> some enterprise environments with many generic apps IDs.


More people have encountered this situation and wrote scponly (google
the term). Use the scponlyc binary if you want to chroot it.
  Réponse avec citation
Vieux 09/11/2006, 14h51   #3
mohamed.zubaidi@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: chroot SFTP ONLY


Steven Mocking wrote:
> mohamed.zubaidi@gmail.com wrote:
> > How can we chroot SFTP but NOT SSH sessions for the same user ?
> > I know it doesn't make sense but humor me, this is a requirement in
> > some enterprise environments with many generic apps IDs.

>
> More people have encountered this situation and wrote scponly (google
> the term). Use the scponlyc binary if you want to chroot it.


to my understanding the scponly is a shell-like binrary you specify in
the passwd file so users will be able to SFTP and SCP but NOT SSH to
the machine and can chroot the sftp/scp session as well.

However, I want the user to be able to login with ssh wihtout being
chrooted while when he uses sftp, gets chrooted. I'm using a config
file for this and it's working fine for both now I just need to
seperate them. I'm looking for a way for identify the connection as an
sftp session prior to the do_setusercontext function in session.c

MJ

  Réponse avec citation
Vieux 09/11/2006, 19h44   #4
Steven Mocking
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: chroot SFTP ONLY

mohamed.zubaidi@gmail.com wrote:
> However, I want the user to be able to login with ssh wihtout being
> chrooted while when he uses sftp, gets chrooted. I'm using a config
> file for this and it's working fine for both now I just need to
> seperate them. I'm looking for a way for identify the connection as an
> sftp session prior to the do_setusercontext function in session.c


Ouch, should've read your first post more literally. If I recall
correctly the chroot system call can only be made as root and the
sftp-server is run as a subsystem request by a user inside the ssh
session. That's why it's FTP *over* SSH. Before that, there is not
really something specific which tells you if a session is sftp or shell.

Perhaps you could patch/modify the sftp-server sourcecode to do
something like

uid_t uid = getuid(); chroot("/path/to/chroot"); seteuid(uid);

very early on in the code. Then make the compiled binary setuid root. Be
careful though, because there is always the danger of holes with setuid
root binaries, like users setting LD_LIBRARY_PATH and LD_PRELOAD.
  Réponse avec citation
Vieux 10/11/2006, 02h46   #5
mohamed.zubaidi@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: chroot SFTP ONLY


Steven Mocking wrote:
> If I recall
> correctly the chroot system call can only be made as root and the
> sftp-server is run as a subsystem request by a user inside the ssh
> session. That's why it's FTP *over* SSH. Before that, there is not
> really something specific which tells you if a session is sftp or shell.
>
> Perhaps you could patch/modify the sftp-server sourcecode to do
> something like
>
> uid_t uid = getuid(); chroot("/path/to/chroot"); seteuid(uid);
>
> very early on in the code. Then make the compiled binary setuid root. Be
> careful though, because there is always the danger of holes with setuid
> root binaries, like users setting LD_LIBRARY_PATH and LD_PRELOAD.


I wanted to patch the session.c only to make it easier to port (on
hundreds of hybrid UNIX systems) but after reading most of the SSH code
with no clues, I guess your right the only way to go would be to patch
the sftp-server.c as well.

The best way to go is to seperate sftp users from login ones and chroot
normally (both) as required. but it's worth investigating

Thanks anyway Steve,
MJ

  Réponse avec citation
Vieux 12/11/2006, 02h45   #6
Doug Spencer
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: chroot SFTP ONLY

I got this working. My findings are at:

http://www.securitybulletins.com/med...ot_environment

Doug

On 7 Nov 2006 11:39:49 -0800
mohamed.zubaidi@gmail.com wrote:

> I saw this problem posted on many places with no solution so far.
>
> How can we chroot SFTP but NOT SSH sessions for the same user ?
> I know it doesn't make sense but humor me, this is a requirement in
> some enterprise environments with many generic apps IDs.


--
For UNIX, Linux and security articles
visit http://SecurityBulletins.com/
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 20h11.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,11240 seconds with 14 queries