Bug 1527 - ForceCommand internal-sftp needs a way to enable logging
Summary: ForceCommand internal-sftp needs a way to enable logging
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: sftp-server (show other bugs)
Version: 5.1p1
Hardware: Itanium2 HP-UX
: P4 minor
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-09-24 00:32 AEST by Olivier S. Masse
Modified: 2009-02-23 13:36 AEDT (History)
1 user (show)

See Also:


Attachments
fix forcecommand internal-sftp (1.58 KB, patch)
2008-09-24 03:07 AEST, Damien Miller
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier S. Masse 2008-09-24 00:32:16 AEST
I'm reporting a problem that I've seen a few times by googling, and there doesn't seem to be a bug report on this yet.

When setting up an SFTP-only server, Damien suggested in the OpenBSD journal to use a combination of ChrootDirectory and ForceCommand like this. I've added the sftp subsystem as well since it's required.

Subsystem sftp internal-sftp
ForceCommand internal-sftp
ChrootDirectory /chroot

The previous settings work well as documented.

However, since internal-sftp doesn't do any logging by default, to enable SFTP logging, this could be used in theory:

Subsystem sftp internal-sftp -l VERBOSE
ForceCommand internal-sftp
ChrootDirectory /chroot

That doesn't log anything either, the SFTP connection works but no logging is performed. Just for your information, the jailed /dev/log requirement is met.

Let's try this one:

Subsystem sftp internal-sftp -l VERBOSE
ForceCommand internal-sftp -l VERBOSE
ChrootDirectory /chroot

With these settings, connection is closed immediately by sshd. 

Just to illustrate my point, let's run a debug SFTP session with ForceCommand commented out:

Subsystem sftp internal-sftp -l VERBOSE
#ForceCommand internal-sftp -l VERBOSE
ChrootDirectory /chroot

This time SFTP works, logs detailed information as expected in the chrooted /dev/log, and gives me this:

debug1: subsystem: exec() internal-sftp -l VERBOSE
debug1: audit run command euid 0 user ftpitst command 'internal-sftp -l VERBOSE'

So far so good. But if I put back ForceCommand in place, it closes the connection immediately and gives me this:

debug1: subsystem: exec() internal-sftp -l VERBOSE
debug1: Forced command (config) 'internal-sftp -l VERBOSE'
debug1: audit run command euid 0 user ftpitst command 'internal-sftp -l VERBOSE'

I'll be glad to provide more information if necessary.

Thanks
Comment 1 Damien Miller 2008-09-24 03:07:14 AEST
Created attachment 1569 [details]
fix forcecommand internal-sftp

This patch fixes the problem, it has already been committed and will be in openssh-5.2.
Comment 2 Damien Miller 2009-02-23 13:36:31 AEDT
Close bugs fixed/reviewed for openssh-5.2 release