我正在使用以下配置构建curl:
./configure --with-ssl --with-libssh2 --prefix=/home/yuvi/development/curlssh
配置完成后,我可以看到SCP已启用。
curl version: 7.24.0
Host setup: x86_64-unknown-linux-gnu
Install prefix: /home/yuvi/development/curlssh
Compiler: gcc
SSL support: enabled (OpenSSL)
SSH support: enabled (libSSH2)
zlib support: enabled
krb4 support: no (--with-krb4*)
GSSAPI support: no (--with-gssapi)
SPNEGO support: no (--with-spnego)
TLS-SRP support: no (--enable-tls-srp)
resolver: default (--enable-ares / --enable-threaded-resolver)
ipv6 support: enabled
IDN support: no (--with-libidn)
Build libcurl: Shared=yes, Static=yes
Built-in manual: enabled
Verbose errors: enabled (--disable-verbose)
SSPI support: no (--enable-sspi)
ca cert bundle: /etc/ssl/certs/ca-certificates.crt
ca cert path: 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)
Protocols: DICT FILE FTP FTPS GOPHER HTTP HTTPS IMAP IMAPS POP3 POP3S RTSP SCP SFTP SMTP SMTPS TELNET TFTP
但是当我运行示例程序时,我收到以下错误:
* Protocol scp not supported or disabled in libcurl
* Unsupported protocol
我的网址是:
curl_easy_setopt(curl, CURLOPT_URL,"scp://192.168.10.1/mnt/dev.zip");
我能够通过SCP使用命令提示检索文件,这意味着远程服务器支持SCP。那我在哪里做错了??
谢谢, Yuvi
答案 0 :(得分:0)
我会尝试LD_PRELOAD以确保程序使用正确的libcurl.so
。类似的东西:
LD_PRELOAD=/home/user/curl-7.24.0/lib/.libs/libcurl.so ldd ./sample-program
LD_PRELOAD=/home/user/curl-7.24.0/lib/.libs/libcurl.so ./sample-program
如果与静态库libcurl.a
链接,程序包含几个符号scp
作为子字符串:
$ nm sample-program | grep scp
08092be0 R Curl_handler_scp
U libssh2_scp_recv
U libssh2_scp_send64
080789e0 t scp_disconnect
08078bd0 t scp_doing
08078b00 t scp_done
08074a80 t scp_recv
080749f0 t scp_send
这假设curl已经编译并启用了调试(-g),并且调试符号未从sample-program
中删除。如果nm sample-program | grep scp
的输出为空,则:
libcurl.a
编译而不支持SCP协议,或libcurl.so
(而不是静态库libcurl.a
)