JVerstry JVerstry - 11 months ago 66
Linux Question

How to get sftp version of remote server?

As part of trying to debug an issue, I would like to know which version of sftp is installed on the remote server where I am trying to push files.

I was told to use

at the command line, but I can't any documentation about it. Is there any other option? My server is Linux based.

My other question is: say two servers have not installed the same version of SFTP, is there a kind of protocol version negotiation to make sure they 'speak the same language'?

Answer Source

To get the remote SSH version, you can telnet to the ssh port. The remote ssh server will send its software version string:

$ telnet localhost 22
Trying ::1...
Connected to localhost.
Escape character is '^]'.

In ssh debug output, you'd look for these lines:

debug1: Local version string SSH-2.0-OpenSSH_6.9
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.9

The first line is the version of your local client. The second line is the remote server's ssh protocol and software version.

What you're looking for here is the "OpenSSH_6.9" part. That tells you the remote server is OpenSSH. The actual SFTP server will almost certainly be the [sftp-server][1] program that comes with that version of OpenSSH.

If you specifically want the SFTP protocol version, the sftp command-line utility has a "version" command which prints the negotiated protocol version:

sftp> version
SFTP protocol version 3

You can also get it by running "sftp -vv" and looking for this line of debug output:

debug2: Remote version: 3

Note that OpenSSH is by far the most widely used SSH server, and it uniformly implements SFTP version 3.

I'll add that there's no real documentation for OpenSSH debug output. The way to understand it is to download a copy of the source and figure out which debug messages have the information that you want.