Discussion:
Diagnosing sftp problems?
Kevin R. Bulgrien
2018-08-14 20:46:32 UTC
Permalink
I'm working with a very old OS, and attempting to build the latest curl on
it. For the most part, I've succeeded with the caveat that sftp does not
seem to work, but appears to be present as a feature.

My ./configure output is:

configure: Configured to build curl/libcurl:

curl version: 7.61.0
Host setup: i686-pc-sco3.2v5.0.7
Install prefix: /path/to/kevinb
Compiler: gcc
SSL support: enabled (OpenSSL)
SSH support: enabled (libSSH2)
zlib support: enabled
brotli support: no (--with-brotli)
GSS-API support: no (--with-gssapi)
TLS-SRP support: enabled
resolver: default (--enable-ares / --enable-threaded-resolver)
IPv6 support: no (--enable-ipv6)
Unix sockets support: enabled
IDN support: no (--with-{libidn2,winidn})
Build libcurl: Shared=yes, Static=yes
Built-in manual: enabled
--libcurl option: enabled (--disable-libcurl-option)
Verbose errors: enabled (--disable-verbose)
SSPI support: no (--enable-sspi)
ca cert bundle: no
ca cert path: no
ca fallback: no
LDAP support: no (--enable-ldap / --with-ldap-lib / --with-lber-lib)
LDAPS support: no (--enable-ldaps)
RTSP support: enabled
RTMP support: no (--with-librtmp)
metalink support: no (--with-libmetalink)
PSL support: no (libpsl not found)
HTTP2 support: disabled (--with-nghttp2)
Protocols: DICT FILE FTP FTPS GOPHER HTTP HTTPS IMAP IMAPS POP3 POP3S RTSP SCP SFTP SMB SMBS SMTP SMTPS TELNET TFTP

The statically built binary says:

curl 7.61.0 (i686-pc-sco3.2v5.0.7) libcurl/7.61.0 OpenSSL/1.0.2o zlib/1.2.11 libssh2/1.1
Release-Date: 2018-07-11
Protocols: dict file ftp ftps gopher http https imap imaps pop3 pop3s rtsp scp sftp smtp smtps telnet tftp
Features: NTLM NTLM_WB SSL libz TLS-SRP UnixSockets HTTPS-proxy

However, when I attempt an sftp transfer, I get:

$ curl -v -k -u user 'sftp://192.168.1.250/~/testfile.txt'
Enter host password for user 'user':
* Trying 192.168.1.250...
* TCP_NODELAY set
* Connected to 192.168.1.250 (192.168.1.250) port 22 (#0)
* Failure establishing ssh session
* Closing connection 0
curl: (2) Failure establishing ssh session

I can perform the same operation with sftp just fine.

$ sftp ***@192.168.1.250:testfile.txt .
Enter passphrase for key '/path/to/kevinb/.ssh/id_rsa':
***@192.168.1.250's password:
Connected to 192.168.1.250.
Fetching /path/to/user/testfile.txt to ./testfile.txt
/path/to/user/testfile.txt 100% 129KB 2.2MB/s 00:00

If you notice libssh2 is very old, this is because I had trouble compiling
newer versions and haven't figured out how to fix the build issues.

curl seems to work otherwise.

Any thoughts on how I might drill down on this to figure out what is going
wrong?

I tried --trace / --trace-ascii as help says it gives more detail, but it
actually gives less detail:

$ curl --trace -k -u user 'sftp://192.168.1.250/~/testfile.txt'
Enter host password for user 'user':
curl: (2) Failure establishing ssh session

I did try using truss also:

$ truss curl -v -k -u user 'sftp://192.168.1.250/~/testfile.txt'
found ELF header 1 at virtual address 80001000
found ELF header 2 at virtual address 80090000
sysi86(SI86GETFEATURES, 0x8008c048, 0xf, 0x800887b0, 0x4, 0x0) = 12
pipe(114, -2146910136, 15, -2146924624, 4, 0) = 3
close(3) = 0
close(4) = 0
brk(0x823df8c) = 0
open("/path/to/kevinb/ssl/openssl.cnf", 0x0, 0x1b6) = 3
ioctl(3, TCGETA, 0x80475a2) = ENOTTY
fxstat(51, 3, 0x80475d4) = 0
brk(0x823ef8c) = 0
read(3, "#\n# OpenSSL example configuration file.\n# This i...", 1024) = 1024
read(3, "efault ca section\n\n#############################...", 1024) = 1024
read(3, "tions\ncert_opt \09 = ca_default\09 \09 # Certific...", 1024) = 1024
read(3, " 'object'\n# types.\n[ policy_anything ]\ncountryN...", 1024) = 1024
brk(0x823ff8c) = 0
read(3, "Netscape crash on BMPStrings or UTF8Strings.\nstri...", 1024) = 1024
read(3, "challenge password\nchallengePassword_min\09 \09 =...", 1024) = 1024
read(3, "X recommendations harmless if included in all cert...", 1024) = 1024
read(3, "ue\n# So we do this instead.\nbasicConstraints = C...", 1024) = 1024
read(3, " this to avoid interpreting an end user certificat...", 1024) = 1024
read(3, "hat aren't\n# deprecated according to PKIX.\n# sub...", 1024) = 1024
brk(0x8240f8c) = 0
read(3, " Policy if request did not specify it\n\09 \09 \09...", 1024) = 595
read(3, "NULL, 1024) = 0
close(3) = 0
open("/usr/lib/nls/msg/C_C.C/unixds/syserr", 0x0, 0x800887b0) = ENOENT
open("/usr/lib/nls/msg/C_C/unixds/syserr", 0x0, 0x800887b0) = ENOENT
open("/usr/lib/nls/msg/C/unixds/syserr", 0x0, 0x800887b0) = ENOENT
open("/etc/nls/msg/C_C.C/unixds/syserr", 0x0, 0x800887b0) = ENOENT
open("/etc/nls/msg/C_C/unixds/syserr", 0x0, 0x800887b0) = ENOENT
open("/etc/nls/msg/C/unixds/syserr", 0x0, 0x800887b0) = ENOENT
open("/usr/lib/nls/msg/C_C.C/unixds/syserr.m", 0x0, 0x800887b0) = ENOENT
open("/usr/lib/nls/msg/C_C/unixds/syserr.m", 0x0, 0x800887b0) = ENOENT
open("/usr/lib/nls/msg/C/unixds/syserr.m", 0x0, 0x800887b0) = ENOENT
open("/etc/nls/msg/C_C.C/unixds/syserr.m", 0x0, 0x800887b0) = ENOENT
open("/etc/nls/msg/C_C/unixds/syserr.m", 0x0, 0x800887b0) = ENOENT
open("/etc/nls/msg/C/unixds/syserr.m", 0x0, 0x800887b0) = ENOENT
open("/usr/lib/nls/msg/C_C.C/unixds/syserr", 0x0, 0x800887b0) = ENOENT
open("/usr/lib/nls/msg/C_C/unixds/syserr", 0x0, 0x800887b0) = ENOENT
open("/usr/lib/nls/msg/C/unixds/syserr", 0x0, 0x800887b0) = ENOENT
open("/etc/nls/msg/C_C.C/unixds/syserr", 0x0, 0x800887b0) = ENOENT
open("/etc/nls/msg/C_C/unixds/syserr", 0x0, 0x800887b0) = ENOENT
open("/etc/nls/msg/C/unixds/syserr", 0x0, 0x800887b0) = ENOENT
open("/usr/lib/nls/msg/C_C.C/unixds/syserr.m", 0x0, 0x800887b0) = ENOENT
open("/usr/lib/nls/msg/C_C/unixds/syserr.m", 0x0, 0x800887b0) = ENOENT
open("/usr/lib/nls/msg/C/unixds/syserr.m", 0x0, 0x800887b0) = ENOENT
open("/etc/nls/msg/C_C.C/unixds/syserr.m", 0x0, 0x800887b0) = ENOENT
open("/etc/nls/msg/C_C/unixds/syserr.m", 0x0, 0x800887b0) = ENOENT
open("/etc/nls/msg/C/unixds/syserr.m", 0x0, 0x800887b0) = ENOENT
brk(0x8241f8c) = 0
brk(0x8242f8c) = 0
brk(0x8243f8c) = 0
brk(0x8244f8c) = 0
brk(0x8245f8c) = 0
brk(0x8246f8c) = 0
brk(0x8247f8c) = 0
brk(0x8249f8c) = 0
brk(0x824af8c) = 0
brk(0x824bf8c) = 0
brk(0x824cf8c) = 0
brk(0x824df8c) = 0
brk(0x824ef8c) = 0
brk(0x8252f8c) = 0
brk(0x8256f8c) = 0
open("/etc/default/lang", 0x0, 0x800887b0) = 3
read(3, "#\09 @(#) lang.src 58.1 96/10/09 \n#\n#\09 Copyrig...", 1024) = 542
lseek(3, 0x1df, 0) = 479
close(3) = 0
access("/usr/lib/locale/", 0x4) = 0
access("/usr/lib/lang/", 0x4) = 0
eaccess("/usr/lib/lang/C/C/C/currency", 4) = 0
eaccess("/usr/lib/lang/C/C/C/messages", 4) = 0
eaccess("/usr/lib/lang/C/C/C/collate", 4) = 0
eaccess("/usr/lib/lang/C/C/C/time", 4) = 0
open("/usr/lib/lang/C/C/C/ctype", 0x0, 0x800887b0) = 3
read(3, "\01 \00 ((((( H\10 \10 \...", 528) = 515
close(3) = 0
open("/usr/lib/lang/C/C/C/numeric", 0x0, 0x800887b0) = 3
fxstat(51, 3, 0x8047764) = 0
read(3, "\02 .\00 \00 \00 ", 5) = 5
close(3) = 0
open("/path/to/kevinb/.curlrc", 0x0, 0x1b6) = ENOENT
open("/dev/tty", 0x0, 0x8047638) = 3
ioctl(3, TCGETA, 0x80475da) = 0
ioctl(3, TCSETAF, 0x80475da) = 0
Enter host password for user 'user':write(2, "Enter host password for user 'user':", 39) = 39
read(3, "\80 ", 1) = ... (sleeping)
read(3, "N", 1) = 1
read(3, "o", 1) = 1
read(3, "t", 1) = 1
read(3, "T", 1) = 1
read(3, "h", 1) = 1
read(3, "e", 1) = 1
read(3, "R", 1) = 1
read(3, "e", 1) = 1
read(3, "a", 1) = 1
read(3, "l", 1) = 1
read(3, "P", 1) = 1
read(3, "a", 1) = 1
read(3, "s", 1) = 1
read(3, "s", 1) = 1
read(3, "w", 1) = 1
read(3, "o", 1) = 1
read(3, "r", 1) = 1
read(3, "d", 1) = 1
read(3, "!", 1) = 1
read(3, ":", 1) = 1
read(3, "v", 1) = 1
read(3, "\n", 1) = 1
ioctl(3, TCSETAW, 0x80475da) = 0

write(2, "\n", 1) = 1
close(3) = 0
brk(0x8257f8c) = 0
ioctl(1, TCGETA, 0x80474e2) = 0
brk(0x8270f8c) = 0
ioctl(0, TIOCGWINSZ, 0x80474fc) = 0
gettimeofday(0x8047500) = 0
brk(0x8275f8c) = 0
brk(0x8279f8c) = 0
gettimeofday(0x8047420) = 0
gettimeofday(0x8047350) = 0
gettimeofday(0x8047400) = 0
gettimeofday(0x8047400) = 0
gettimeofday(0x8047330) = 0
gettimeofday(0x8047340) = 0
gettimeofday(0x8047350) = 0
gettimeofday(0x80472a0) = 0
gettimeofday(0x80472b0) = 0
gettimeofday(0x80472c0) = 0
gettimeofday(0x8047270) = 0
sigprocmask(0, 0x0, 0x823c6bc) = 0
alarm(299) = 0
time(0x12b) = 1534278606
alarm(0) = 299
gettimeofday(0x80472d0) = 0
gettimeofday(0x8047310) = 0
gettimeofday(0x80472d0) = 0
*write(2, "*", 1) = 1
write(2, " ", 1) = 1
Trying 192.168.1.250...
write(2, " Trying 192.168.1.250...\n", 26) = 26
*write(2, "*", 1) = 1
write(2, " ", 1) = 1
TCP_NODELAY set
write(2, "TCP_NODELAY set\n", 16) = 16
fcntl(3, 3, 0) = 2
fcntl(3, 4, 130) = 0
gettimeofday(0x8047130) = 0
gettimeofday(0x8047290) = 0
gettimeofday(0x8047310) = 0
gettimeofday(0x8047310) = 0
gettimeofday(0x80472b0) = 0
gettimeofday(0x8047300) = 0
poll(134509296, 1, 0, -2146924624, 4, 0) = 1
gettimeofday(0x80472c0) = 0
*write(2, "*", 1) = 1
write(2, " ", 1) = 1
Connected to 192.168.1.250 (192.168.1.250) port 22 (#0)
write(2, "Connected to 192.168.1.250 (192.168.1.250) port 22...", 56) = 56
gettimeofday(0x80472b0) = 0
brk(0x827df8c) = 0
fcntl(3, 3, 0) = 130
*write(2, "*", 1) = 1
write(2, " ", 1) = 1
Failure establishing ssh session
write(2, "Failure establishing ssh session\n", 33) = 33
gettimeofday(0x80472b0) = 0
gettimeofday(0x8047350) = 0
gettimeofday(0x8047400) = 0
gettimeofday(0x8047400) = 0
gettimeofday(0x80470d0) = 0
gettimeofday(0x8047130) = 0
time(0x8047130) = 1534278606
time(0x8047130) = 1534278606
*write(2, "*", 1) = 1
write(2, " ", 1) = 1
Closing connection 0
write(2, "Closing connection 0\n", 21) = 21
close(3) = 0
cwrite(2, "c", 1) = 1
uwrite(2, "u", 1) = 1
rwrite(2, "r", 1) = 1
lwrite(2, "l", 1) = 1
:write(2, ":", 1) = 1
write(2, " ", 1) = 1
(write(2, "(", 1) = 1
2write(2, "2", 1) = 1
)write(2, ")", 1) = 1
write(2, " ", 1) = 1
Fwrite(2, "F", 1) = 1
awrite(2, "a", 1) = 1
iwrite(2, "i", 1) = 1
lwrite(2, "l", 1) = 1
uwrite(2, "u", 1) = 1
rwrite(2, "r", 1) = 1
ewrite(2, "e", 1) = 1
write(2, " ", 1) = 1
ewrite(2, "e", 1) = 1
swrite(2, "s", 1) = 1
twrite(2, "t", 1) = 1
awrite(2, "a", 1) = 1
bwrite(2, "b", 1) = 1
lwrite(2, "l", 1) = 1
iwrite(2, "i", 1) = 1
swrite(2, "s", 1) = 1
hwrite(2, "h", 1) = 1
iwrite(2, "i", 1) = 1
nwrite(2, "n", 1) = 1
gwrite(2, "g", 1) = 1
write(2, " ", 1) = 1
swrite(2, "s", 1) = 1
swrite(2, "s", 1) = 1
hwrite(2, "h", 1) = 1
write(2, " ", 1) = 1
swrite(2, "s", 1) = 1
ewrite(2, "e", 1) = 1
swrite(2, "s", 1) = 1
swrite(2, "s", 1) = 1
iwrite(2, "i", 1) = 1
owrite(2, "o", 1) = 1
nwrite(2, "n", 1) = 1

write(2, "\n", 1) = 1
Process 24921 terminated normally with 2
Child process has exited

Any thoughts other than figuring out how to fix the compile errors on a
newer libssh2?
--
Kevin R. Bulgrien
Computer Systems Design, Inc dba Systems Design
-----------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-users
Etiquette: https:
Daniel Stenberg
2018-08-14 21:01:44 UTC
Permalink
Post by Kevin R. Bulgrien
curl 7.61.0 (i686-pc-sco3.2v5.0.7) libcurl/7.61.0 OpenSSL/1.0.2o zlib/1.2.11 libssh2/1.1
...
Post by Kevin R. Bulgrien
If you notice libssh2 is very old, this is because I had trouble compiling
newer versions and haven't figured out how to fix the build issues.
I think that's a good start. That libssh2 version is over nine years old.
Post by Kevin R. Bulgrien
I tried --trace / --trace-ascii as help says it gives more detail, but it
$ curl --trace -k -u user 'sftp://192.168.1.250/~/testfile.txt'
--trace and --trace-ascii need a file name too, which you set to '-k' ...
Post by Kevin R. Bulgrien
Failure establishing ssh session
That's libssh2's libssh2_session_startup() function that returns error...
--
/ daniel.haxx.se
-----------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-users
Etiquette: https://curl.haxx.se/mai
Loading...