Hello, I tried setting up sshd for chrooted login and sftp-only access. My /etc/ssh/sshd_config contains (among other stuff): Subsystem sftp /usr/lib/openssh/sftp-server Match User foo ChrootDirectory /srv/foo ForceCommand internal-sftp The "Subsystem" option is set by default on debian systems. The manual page says for "ForceCommand": Specifying a command of “internal-sftp” will force the use of an in-process sftp server that requires no support files when used with ChrootDirectory. When I connect with sftp, sftp requests the subsystem 'sftp'. The output from sshd is: subsystem request for sftp subsystem: cannot stat /usr/lib/openssh/sftp-server: No such file or directory subsystem request for sftp failed, subsystem not found Connection closed by 127.0.0.1 Setting "Subsystem sftp internal-sftp" works around the problem, but that option is not allowed inside a Match block. If the stat() call in session_subsystem_req succeeds, is_subsystem is set to SUBSYSTEM_EXT; then do_exec is called, it overrides this and sets is_subsystem = SUBSYSTEM_INT_SFTP. I believe that calling stat() on the external program and then calling the internal sftp handler is not intended behaviour. Regards Jörn Heissler
look at this for 5.4
Created attachment 1697 [details] downgrade error message on subsystem executable stat() failure to debug I think we can downgrade the error to a warning, but I need to check. dtucker also points out that this will allow the use of subsystems on restricted shells that disallow absolute paths.
Comment on attachment 1697 [details] downgrade error message on subsystem executable stat() failure to debug >Index: session.c >=================================================================== >RCS file: /cvs/src/usr.bin/ssh/session.c,v >retrieving revision 1.247 >diff -u -p -r1.247 session.c >--- session.c 6 Oct 2009 04:46:40 -0000 1.247 >+++ session.c 6 Oct 2009 04:54:18 -0000 >@@ -1717,11 +1717,10 @@ session_subsystem_req(Session *s) > cmd = options.subsystem_args[i]; > if (!strcmp(INTERNAL_SFTP_NAME, prog)) { > s->is_subsystem = SUBSYSTEM_INT_SFTP; >- } else if (stat(prog, &st) < 0) { >- error("subsystem: cannot stat %s: %s", prog, >- strerror(errno)); >- break; > } else { btw: unbalanced bracket >+ if (stat(prog, &st) < 0) { >+ debug("subsystem: cannot stat %s: %s", >+ prog, strerror(errno)); > s->is_subsystem = SUBSYSTEM_EXT; > } > debug("subsystem: exec() %s", cmd);
This has been committed and will be in 5.4. Thanks for the report.
With the release of 5.4p1, this bug is now considered closed.