Re: Chrooted OpenSSH for Windows (rssh sftp cygwin)

2004-11-30 Thread Christian Weinberger
John M. L. john at recaffeinated.com writes:
 I've been trying to implement an sftp server using OpenSSH for Windows
 (http://sshwindows.sourceforge.net).  I haven't found much recent discussion
 on th topic of running OpenSSH in a chrooted jail on cygwin, but the
 following messages from a year ago have shed some light on the topic:

I solved exactly the same problem using scponly 
(http://www.sublimation.org/scponly/)
.
The current version compiles easily under recent Cygwin releases.
You only have to modify the Makefile to include some libraries explicitly.

Id always try to have a binary as a chroot stub and not a shell script. If 
you 
use a shell script, you need bash and several supplemental programs in the 
chroot jail which all may contain security leaks.

The tool that I used has a make option to prepare the chroot jail. It copies 
all required files to the jail. So you may learn from it even if you decide to 
stay with rssh.

Youve to make another decision:
Do you only need to support sftp protocol version 2 or also older versions.
In the first case it should be sufficient to have sftp-server.exe in the chroot 
jail (plus a passwd  group). In the second case, youll need to have things 
like bash, ls, rm and others again.

Hope this helps a bit!
Christian


--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: Chrooted OpenSSH for Windows (rssh sftp cygwin)

2004-11-30 Thread john m lauck
Thanks, Christian!
I actually got the chrooted sftp session to *work* (! shell commands 
still work).  I made these changes:

--
chroot /cygdrive/c/StudentsShare /usr/sbin/sftp-server
--
Basically, I removed the 'exec' from the chroot call.  I thought maybe 
there were insufficient dll's in the chroot C:\StudentsShare.  I copied 
all the local files from the /usr, /bin and /etc folders to my chroot 
and still had the same problem with including the 'exec'.  Does anyone 
know how the exec effects chroot call?  I dont understand how the exec 
makes it more secure by replacing the current script process.
However, this doesn't stop a user from entering a ! command at the sftp 
prompt.  I had some luck setting file privileges/ownership but that 
seems like a dangerous move to chmod/chown all the files outside of 
C:\StudentsShare.

Any ideas are welcome.
Also (in response to Christian Weinberger), I only need SFTP protocol 2.
I prefer to stick to SFTP just because it's easier to transfer a group 
of files and manipulate folders etc.

With time permitting for my project I may give scponly a try.
Christian Weinberger wrote:
John M. L. john at recaffeinated.com writes:
I've been trying to implement an sftp server using OpenSSH for Windows
(http://sshwindows.sourceforge.net).  I haven't found much recent discussion
on th topic of running OpenSSH in a chrooted jail on cygwin, but the
following messages from a year ago have shed some light on the topic:

I solved exactly the same problem using scponly 
(http://www.sublimation.org/scponly/)
.
The current version compiles easily under recent Cygwin releases.
You only have to modify the Makefile to include some libraries explicitly.

Id always try to have a binary as a chroot stub and not a shell script. If you 
use a shell script, you need bash and several supplemental programs in the 
chroot jail which all may contain security leaks.

The tool that I used has a make option to prepare the chroot jail. It copies 
all required files to the jail. So you may learn from it even if you decide to 
stay with rssh.

Youve to make another decision:
Do you only need to support sftp protocol version 2 or also older versions.
In the first case it should be sufficient to have sftp-server.exe in the chroot 
jail (plus a passwd  group). In the second case, youll need to have things 
like bash, ls, rm and others again.

Hope this helps a bit!
Christian


--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/


Chrooted OpenSSH for Windows (rssh sftp cygwin)

2004-11-26 Thread John M. L.
I've been trying to implement an sftp server using OpenSSH for Windows
(http://sshwindows.sourceforge.net).  I haven't found much recent discussion
on th topic of running OpenSSH in a chrooted jail on cygwin, but the
following messages from a year ago have shed some light on the topic:

http://archive.erdelynet.com/ssh-l/2003-10/msg00057.php

http://www.cygwin.com/ml/cygwin/2003-08/msg00738.html

http://cygwin.com/ml/cygwin/2003-07/msg01500.html

I almost have the system running on Windows 2000 Server.  Using the ssh
server without chroot is fine.  However, when I try to connect using the
chrooted sftp shell it automatically disconnects the user.  Using WinSCP3 to
connect returns at cryptic error code 127 and a command line sftp just dies
silently with no explanation.

Here's my current login shell script for users:

#!/bin/sh
#echo Parameters: $@  /home/sshlogin.log
if [ $* != -c /usr/sbin/sftp-server ]; then
   echo Sorry, sftp only!
   exit 1
fi

#without chroot works!
exec /bin/sh -i $@

#with chroot no such luck
#chroot /cygdrive/c/StudentsShare exec /bin/sh -i $@


I'm assuming part of the problem may be the required files for the /bin/sh
call are not inside the chroot jail /cygdrive/c/StudentsShare.  If this is
the case, I would like to know if anyone could let me know what files should
be included.  At first I got Cygwin dll errors stating that cyg*.* could not
be found. They stopped once I moved the files into the jail and/or fixed
environment path variables.

I have two log files using sshd -d -d -d for high debug output.  They can be
found here:

Chrooted log:
http://john.isosceles7.com/files/login_chroot.txt

Un Chrooted log
http://john.isosceles7.com/files/login_nochroot.txt

The debug is cryptic, but if I think the error in the chroot is around line
116.  Here's an excerpt of this piece


Chrooted log (lines 112-126):

subsystem request for sftp
debug1: subsystem: exec() /usr/sbin/sftp-server
debug2: fd 10 setting O_NONBLOCK
debug2: fd 9 setting O_NONBLOCK
debug2: channel 0: read=0 rfd 10 len 0
debug1: Received SIGCHLD.
debug2: channel 0: read failed
debug2: channel 0: close_read
debug2: channel 0: input open - drain
debug2: channel 0: ibuf empty
debug2: channel 0: send eof
debug2: channel 0: input drain - closed
debug2: notify_done: reading
debug1: session_by_pid: pid 1364
debug1: session_exit_message: session 0 channel 0 pid 1364

Un Chrooted log (lines 112-126):

subsystem request for sftp
debug1: subsystem: exec() /usr/sbin/sftp-server
debug2: fd 10 setting O_NONBLOCK
debug2: fd 9 setting O_NONBLOCK
debug2: channel 0: rcvd eof
debug2: channel 0: output open - drain
debug2: channel 0: obuf empty
debug2: channel 0: close_write
debug2: channel 0: output drain - closed
debug1: Received SIGCHLD.
debug1: session_by_pid: pid 1368
debug1: session_exit_message: session 0 channel 0 pid 1368
debug2: channel 0: request exit-status
debug1: session_exit_message: release channel 0
debug1: session_close: session 0 pid 1368


Any help on my problem would be appreciated!  Of course if any other
background information is helpful I will gladly contribute!


... An additional note:  The new cygwin dll 1.5.12-1 source includes
wordexp.h which was a problem that prohibited using rssh
(http://www.pizzashack.org) instead of chrooting openssh.  Does anyone know
how this will affect rssh?



Thanks,

John M Lauck



--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/