Bug 273397

Summary: kio_sftp does not work with ProxyCommand
Product: [Frameworks and Libraries] kio Reporter: Alex Hermann <gaaf>
Component: sftpAssignee: Andreas Schneider <asn>
Status: RESOLVED UPSTREAM    
Severity: normal CC: adawit, b.brachaczek, doktor.yak, info, lacsilva, niklas.laxstrom
Priority: NOR    
Version: 4.6   
Target Milestone: ---   
Platform: Debian unstable   
OS: Linux   
Latest Commit: Version Fixed In:

Description Alex Hermann 2011-05-16 10:20:19 UTC
Version:           4.6 (using KDE 4.6.2) 
OS:                Linux

When ProxyCommand is configured in ~/.ssh/config for a host, an sftp connection to that host fails with the following error message in konqueror:

Details of the Request:
URL: sftp://TARGETHOST
Protocol: sftp
Date and Time: Monday 16 May 2011 10:00
Additional Information: Protocol mismatch: usage: ssh [-1246AaCfgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]

Description:
The server TARGETHOST refused to allow this computer to make a connection.


The ~/.ssh/config settings for the target host and the jumphost used in the ProxyCommand:

Host JUMPHOST
    ProxyCommand none

Host TARGETHOST
    ProxyCommand ssh -q -A -X -W %h:%p JUMPHOST
#    ProxyCommand ssh -q -A -X JUMPHOST nc -q -1 %h %p


- Connecting to that same host works from the command-line and through kio_fish.

- Connecting through kio_sftp to a host which does not need a ProxyCommand works (identically configured target host, same ssh etc.)

- I included 2 ProxyCommands above (one traditional with netcat, one for newer ssh versions supporting -W), both versions fail with kio_sftp, both work with command-line client and kio_fish.

Reproducible: Always

Steps to Reproduce:
Configure a ProxyCommand for a host

Actual Results:  
Connection failure

Expected Results:  
Connection to the target host by using the configure ProxyCommand.

OS: Linux (x86_64) release 2.6.38-2-amd64
Compiler: gcc
Comment 1 Luis Silva 2011-05-16 20:54:35 UTC
I can confirm this behavior.
Comment 2 Andreas Schneider 2011-05-16 21:02:16 UTC
Thanks for taking the time reporting this bug.

Could you please file this upstream. This is a bug in libssh.

http://red.libssh.org/


Thanks!
Comment 3 Ivan Topolsky 2013-04-10 02:39:07 UTC
Seems to be a config file mis-interpretation.

libssh requires the ProxyCommand to be quoted. This doesn't follow ssh's behaviour.


In details:

Without quotes ' ProxyCommand ssh -q -A -X -W %h:%p JUMPHOST ' (as per ssh documentation, and as written in the exemple) :
- SSH loads the whole line 'ssh -q -A -X -W %h:%p JUMPHOST', and try (successfully to run ssh with the specified parameters). i.e.: SSH loads the line with the blanks, and then splits them before running, to separate executable name from the parameters.
- libssh loads the first string 'ssh' and fails at running 'ssh' alone. i.e.: libssh splits blanks first and thus only loads first part.

With quotes ' ProxyCommand "ssh -q -A -X -W %h:%p JUMPHOST" ' (Wrong!)
- SSH loads the whole line including the quotes, and thus tries to run a non-existing executable file called "ssh -q -A -X -W %h:%p JUMPHOST" (i.e.: blanks as part of the executable names ) with no parameters (i.e.: parameters should have been split outside the quote), and fails. 
- libssh loads the sting inside the quotes without the quotes themeselves and runs ssh with specified parameters. (i.e.: it splits the blanks inside the quoted string to separate executable name from parameters. Blanks outside the quotes are discarded).
Comment 4 Niklas Laxström 2014-03-31 09:35:08 UTC
According to https://red.libssh.org/issues/103 upstream should be fixed, but this is still not working.

Can somebody clarify the situation?
Comment 5 Alvin 2014-04-08 13:49:38 UTC
It is fixed, but you'll need the patched libssh version.
(For example, it's working on Kubuntu 10.04, with libssh 0.6.1, scheduled for release this month.)
Comment 6 Niklas Laxström 2014-05-23 08:47:46 UTC
I have libssh 0.6.3 on Fedora with KDE 4.12.5 and I haven't got it working. Is this combination even supposed to work?

The error I get is "Protocol mismatch: " without any further information. kio_fish says "unable to connect".
Comment 7 Dawit Alemayehu 2014-05-23 10:47:09 UTC
(In reply to comment #6)
> I have libssh 0.6.3 on Fedora with KDE 4.12.5 and I haven't got it working.
> Is this combination even supposed to work?
> 
> The error I get is "Protocol mismatch: " without any further information.
> kio_fish says "unable to connect".

kio_sftp and kio_fish are not the same thing. For kio_sftp you have to use sftp://<address>. If you are having problems with kio_fish, you need to open a bug report for it.