使用libssh2进行SSH隧道连接

时间:2016-09-08 14:35:04

标签: c++ c

我正在尝试通过libssh2进行SSH-TUNNEL。直到现在我用这个命令做到了:

server# sshpass -p password ssh -vvv username@1.2.3.4 -o StrictHostKeyChecking=no -N -D 1.2.3.4:5555

-D 1.2.3.4:5555用于在该端口上打开互联网上的隧道,然后我将其与CURL一起使用:

server# curl --SOCKS5 "1.2.3.4:5555" "www.somesite.com"
-- content of the website --

现在我正在尝试做同样的事情,但是libssh2,因此我需要在C/C++

中执行此操作

我尝试了libssh2

中的两个示例

direct_tcpip.c - > https://www.libssh2.org/examples/direct_tcpip.html

Fingerprint: 5D 75 A3 D9 10 65 D5 C4 6B CA 37 98 26 33 53 24 F8 19 1B F9
Authentication methods: publickey,password
Waiting for TCP connection on 1.2.3.4:5555...
Forwarding connection from 1.2.3.4:58595 here to remote 1.2.3.4:22
read: Connection reset by peer <-- When I use curl command

tcpip-forward.c - &gt; https://www.libssh2.org/examples/tcpip-forward.html

Fingerprint: 5D 75 A3 D9 10 65 D5 C4 6B CA 37 98 26 33 53 24 F8 19 1B F9
Authentication methods: publickey,password
Waiting for TCP connection on 1.2.3.4:5555...
Forwarding connection from 1.2.3.4:58595 here to remote 1.2.3.4:22
The remote client at 1.2.3.4:5555 disconnected! <-- When I use curl command

和curl命令:

server# curl --SOCKS5 "1.2.3.4:5555" "somesite.com" curl: (7) Received invalid version in initial SOCKS5 response.

有什么问题? libssh2是否能够进行隧道掘进?

P.S。该项目兼容C/C++,这就是我放两个标签的原因。

0 个答案:

没有答案