After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 752403 - Fails to connect ("SSH program unexpectedly exited")
Fails to connect ("SSH program unexpectedly exited")
Status: RESOLVED FIXED
Product: gvfs
Classification: Core
Component: sftp backend
1.24.x
Other Linux
: Normal normal
: ---
Assigned To: gvfs-maint
gvfs-maint
Depends on:
Blocks:
 
 
Reported: 2015-07-15 06:39 UTC by Bastien Nocera
Modified: 2015-08-10 06:28 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
sftp: Improve error messages on connection setup (2.09 KB, patch)
2015-07-19 07:54 UTC, Ross Lagerwall
committed Details | Review

Description Bastien Nocera 2015-07-15 06:39:34 UTC
$ gvfs-mount sftp://root@diskstation.local/volume1/music
Error mounting location: SSH program unexpectedly exited

Jul 15 08:35:29 nuvo org.gtk.vfs.Daemon[1984]: ### SFTP: spawn_ssh: /usr/bin/ssh -oForwardX11 no -oForwardAgent no -oPermitLocalCommand no -oClearAllForwardings yes -oProtocol 2 -oNoHostAuthenticationForLocalhost yes -l root -s diskstation.local sftp
Jul 15 08:35:29 nuvo org.gtk.vfs.Daemon[1984]: ### SFTP: handle_login #1 - user: root, host: diskstation.local, port: -1
Jul 15 08:35:30 nuvo org.gtk.vfs.Daemon[1984]: ### SFTP: handle_login #1 - password_save: 0
Jul 15 08:35:30 nuvo org.gtk.vfs.Daemon[1984]: ### SFTP: handle_login #1 - ret_val: 1
Jul 15 08:35:30 nuvo org.gtk.vfs.Daemon[1984]: ** (gvfsd:2038): WARNING **: dbus_mount_reply: Error from org.gtk.vfs.Mountable.mount(): SSH program unexpectedly exited

If the line in the log is the full command, then:
$ /usr/bin/ssh -oForwardX11 no -oForwardAgent no -oPermitLocalCommand no -oClearAllForwardings yes -oProtocol 2 -oNoHostAuthenticationForLocalhost yes -l root -s diskstation.local sftp ; echo $?
command-line line 0: missing argument.
255

$ rpm -qf /usr/bin/ssh
openssh-clients-6.8p1-8.fc22.x86_64
Comment 1 Ross Lagerwall 2015-07-15 07:33:34 UTC
You need to quote the options:

$ /usr/bin/ssh '-oForwardX11 no' '-oForwardAgent no' '-oPermitLocalCommand no' '-oClearAllForwardings yes' '-oProtocol 2' '-oNoHostAuthenticationForLocalhost yes' -l root -s diskstation.local sftp

Of course, since it's a binary protocol, you can't really do anything useful...


My guess is that the NAS is running dropbear or something which either doesn't support sftp or it is incompatible. Do you know what sftp server it is running? Usually you can just scrape the server version by running "nc diskstation.local 22".

Also can you try running the following just to see if it connects properly with the normal command-line sftp client:
$ sftp root@diskstation.local
Connected to diskstation.local.
sftp>
Comment 2 Bastien Nocera 2015-07-15 07:39:35 UTC
(In reply to Ross Lagerwall from comment #1)
> You need to quote the options:
> 
> $ /usr/bin/ssh '-oForwardX11 no' '-oForwardAgent no' '-oPermitLocalCommand
> no' '-oClearAllForwardings yes' '-oProtocol 2'
> '-oNoHostAuthenticationForLocalhost yes' -l root -s diskstation.local sftp

Sure.

> Of course, since it's a binary protocol, you can't really do anything
> useful...
> 
> 
> My guess is that the NAS is running dropbear or something which either
> doesn't support sftp or it is incompatible. Do you know what sftp server it
> is running? Usually you can just scrape the server version by running "nc
> diskstation.local 22".

It says:
SSH-2.0-OpenSSH_6.6p2-hpn14v4

> Also can you try running the following just to see if it connects properly
> with the normal command-line sftp client:
> $ sftp root@diskstation.local
> Connected to diskstation.local.
> sftp>

$ sftp root@diskstation.local 
subsystem request failed on channel 0
Couldn't read packet: Connection reset by peer
Comment 3 Ross Lagerwall 2015-07-18 19:09:55 UTC
(In reply to Bastien Nocera from comment #2)
> > Also can you try running the following just to see if it connects properly
> > with the normal command-line sftp client:
> > $ sftp root@diskstation.local
> > Connected to diskstation.local.
> > sftp>
> 
> $ sftp root@diskstation.local 
> subsystem request failed on channel 0
> Couldn't read packet: Connection reset by peer

It looks like sftp does not work with this device. Perhaps you need to do something like http://forum.synology.com/wiki/index.php/How_to_setup_an_sftp-server

Not a gvfs bug though...
Comment 4 Bastien Nocera 2015-07-18 19:19:29 UTC
(In reply to Ross Lagerwall from comment #3)
> (In reply to Bastien Nocera from comment #2)
> > > Also can you try running the following just to see if it connects properly
> > > with the normal command-line sftp client:
> > > $ sftp root@diskstation.local
> > > Connected to diskstation.local.
> > > sftp>
> > 
> > $ sftp root@diskstation.local 
> > subsystem request failed on channel 0
> > Couldn't read packet: Connection reset by peer
> 
> It looks like sftp does not work with this device. Perhaps you need to do
> something like
> http://forum.synology.com/wiki/index.php/How_to_setup_an_sftp-server
> 
> Not a gvfs bug though...

The dreadful error message is gvfs' problem though.
Comment 5 Ross Lagerwall 2015-07-19 07:54:27 UTC
Created attachment 307667 [details] [review]
sftp: Improve error messages on connection setup

Log all the messages from SSH's stderr.

If the remote server does not have sftp setup correctly, it fails with
"subsystem request failed". Report this as "Connection refused".

If the error is unknown, report it as "Connection failed" rather than
"SSH program unexpectedly exited" which shouldn't be exposed to users.
Comment 6 Ondrej Holy 2015-07-21 09:45:04 UTC
Review of attachment 307667 [details] [review]:

Looks good with the nitpick...

::: daemon/gvfsbackendsftp.c
@@ +344,3 @@
         }
+
+      DEBUG("stderr: %s\n", line);

Missing space before opening parenthesis
Comment 7 Ondrej Holy 2015-07-21 09:45:05 UTC
Review of attachment 307667 [details] [review]:

Looks good with the nitpick...

::: daemon/gvfsbackendsftp.c
@@ +344,3 @@
         }
+
+      DEBUG("stderr: %s\n", line);

Missing space before opening parenthesis
Comment 8 Ross Lagerwall 2015-08-10 06:28:02 UTC
Pushed to master as 0da49dd. Thanks for the review.