Ssh – How OpenSSH determine which sftp-server binary is linked to internal-sftp

sftpsshubuntu-14.04

I met a weird issue about setting up SFTP server by OpenSSH on Ubuntu 14.04.

#Subsystem sftp /usr/lib/openssh/sftp-server
Subsystem sftp internal-sftp

These two lines are used in /etc/ssh/sshd_config file to set SFTP server up, but no matter which line I use, /var/log/auth.log will report error as the following:

Nov 20 16:14:20 <user> sshd[34237]: Accepted password for <user> from 10.1.2.56 port 55028 ssh2
Nov 20 16:14:20 <user> sshd[34248]: subsystem request for sftp
Nov 20 16:14:20 <user> sshd[34248]: error: subsystem: cannot stat /usr/libexec/sftp-server: No such file or directory
Nov 20 16:14:20 <user> sshd[34248]: subsystem request for sftp failed, subsystem not found

When I run locate command to find which sftp-server binary are located, this is the output:

$ locate sftp-server
/usr/lib/sftp-server
/usr/lib/openssh/sftp-server
/usr/share/doc/openssh-sftp-server
/usr/share/man/man8/sftp-server.8.gz
/var/lib/dpkg/info/openssh-sftp-server.list
/var/lib/dpkg/info/openssh-sftp-server.md5sums

I am not asking how to fix this problem. What I am curious about is how sshd determine which sftp-server binary should be used for internal-sftp sub-system, and why that is different from the output of locate command?

locate tells it should be
/usr/lib/openssh/sftp-server or /usr/lib/sftp-server, but sshd always try to find /usr/libexec/sftp-server instead.

Could anyone provide some suggestion here? Any hint are appreciated.

Best Answer

internal-sftp is a keyword that makes OpenSSH sshd use an SFTP server that's included in (linked into) the sshd binary.

It does not refer to any external binary.


So if you use internal-sftp, the sshd should not look for any sftp-server binary. What suggests that your sshd_config is actually not being used.