cURL / Mailing Lists / curl-library / Single Mail

curl-library

SFTP w/ password auth and multi-interface

From: Dmitri Shubin <sbn_at_tbricks.com>
Date: Fri, 09 Dec 2011 19:58:51 +0400

Hello all!

I tried to download a file via SFTP and found that it doesn't work when
using libcurl multi- interface.
Another required condition is that password authentication was used and
was tried second after public key.
If public key authentication succeeded everything is fine.

I was able to reproduce it using hiperfifo example
(docs/examples/hiperfifo.c):

sbn_at_sbn $ ./hiperfifo
Creating named pipe "hiper.fifo"
Now, pipe some URL's into > hiper.fifo
Adding easy 0x1d600f78 to multi 0x1d5dc1f8
(sftp://user:passwd@sbn/home/user/.viminfo)
multi_timer_cb: Setting timeout to 1 ms
* About to connect() to sbn port 22 (#0)
* Trying 10.200.145.79... Progress:
sftp://user:passwd@sbn/home/user/.viminfo (0/0)
* connected
* SFTP 0x1d60a5e8 state change from SSH_STOP to SSH_INIT
* SFTP 0x1d60a5e8 state change from SSH_INIT to SSH_S_STARTUP
* 0x1d600f78 is at send pipe head!
* STATE: CONNECT => WAITCONNECT handle 0x1d609cf8; (connection #0)
Progress: sftp://user:passwd@sbn/home/user/.viminfo (0/0)
* STATE: WAITCONNECT => PROTOCONNECT handle 0x1d609cf8; (connection #0)
Progress: sftp://user:passwd@sbn/home/user/.viminfo (0/0)
Progress: sftp://user:passwd@sbn/home/user/.viminfo (0/0)
socket callback: s=7 e=0x1d600f78 what=IN Adding data: IN
Progress: sftp://user:passwd@sbn/home/user/.viminfo (0/0)
multi_timer_cb: Setting timeout to -1 ms
REMAINING: 1
REMAINING: 1
Progress: sftp://user:passwd@sbn/home/user/.viminfo (0/0)
REMAINING: 1
Progress: sftp://user:passwd@sbn/home/user/.viminfo (0/0)
REMAINING: 1
Progress: sftp://user:passwd@sbn/home/user/.viminfo (0/0)
REMAINING: 1
* SFTP 0x1d60a5e8 state change from SSH_S_STARTUP to SSH_HOSTKEY
* SFTP 0x1d60a5e8 state change from SSH_HOSTKEY to SSH_AUTHLIST
Progress: sftp://user:passwd@sbn/home/user/.viminfo (0/0)
REMAINING: 1
* SSH authentication methods available: publickey,gssapi-with-mic,password
* SFTP 0x1d60a5e8 state change from SSH_AUTHLIST to SSH_AUTH_PKEY_INIT
* Using ssh public key file /home/sbn/.ssh/id_dsa.pub
* Using ssh private key file /home/sbn/.ssh/id_dsa
* SFTP 0x1d60a5e8 state change from SSH_AUTH_PKEY_INIT to SSH_AUTH_PKEY
Progress: sftp://user:passwd@sbn/home/user/.viminfo (0/0)
REMAINING: 1
* SSH public key authentication failed: Username/PublicKey combination
invalid
* SFTP 0x1d60a5e8 state change from SSH_AUTH_PKEY to SSH_AUTH_PASS_INIT
Progress: sftp://user:passwd@sbn/home/user/.viminfo (0/0)
socket callback: s=7 e=0x1d600f78 what=REMOVE
REMAINING: 1

And then it hangs while still having TCP connection to SSHD.

As one can see libcurl canceled timer and removed socket from "multiplexer".

I made a workaround in my application so when it detects this situation
(have running handle but no "event subscriptions") it simply calls
curl_multi_socket_all(). This helped.

I tested libcurl 7.23.1 with libssh2 1.3.0

Thanks!
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-12-09