Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 -vvv 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'?

like image 578
Jérôme Verstrynge Avatar asked Feb 07 '23 04:02

Jérôme Verstrynge


1 Answers

To get the remote SSH version, you can use telnet or nc to connect 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 '^]'.
SSH-2.0-OpenSSH_7.9

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

debug1: Local version string SSH-2.0-OpenSSH_7.9
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.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_7.9" part. That tells you the remote server is OpenSSH. The actual SFTP server will almost certainly be the sftp-server 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.

like image 175
Kenster Avatar answered Feb 08 '23 17:02

Kenster