I'm wondering if there is a way to log commands received by the server. It can be all SSH commands, as long as it includes information on commands related to file transfer.
I'm having issues with an SFTP client and the creator is asking for logs, but I am unable to find any existing logs.
I'm looking to log on both or either CentOS or OS X (although I suspect if it's possible, it'd be similar on both).
OpenSSH versions 4.4p1 and up (which should include the latest version with CentOS 5) have SFTP logging capability built in - you just need to configure it.
Find this in your sshd_config (in centos, file /etc/ssh/sshd_config):
and change it to:
INFO is just one level of detail over what you're seeing by default - it provides detailed information regarding file transfers, permission changes, etc. If you need more info, you can adjust the log level accordingly. The various levels (in order of detail) are:
Anything over VERBOSE is probably more information than you're looking for, but it might be useful.
Finally restart the SSH service to update the changes (centos):
The same switches around logging for sftp-server also work for internal-sftp. Here's an example from my /etc/ssh/sshd_config:
With INFO level logging enabled messages will start showing up under /var/log/messages (at least under Red Hat based Distros):
In order to clearify the comments above:
If you have sftp configured using a jail (chroot environment), you cannot log without additional configuration effort. The log cannot be written in the chroot environment, you need to create a mount bind or a socket. I would recommend using a socket, as it is a feature delivered by syslog-ng as well as rsyslog (and maybe many more).
For those who are using syslog-ng, have a look at this link. For those who are using rsyslog; Hope that helps.