Libsshtunnel
Cross-platform SSH tunnel library to let your networking app connect to a host running behind a SSH server.
Install / Use
/learn @bk138/LibsshtunnelREADME
About
libsshtunnel is a simple SSH tunnel library to let your networking app connect to a host running behind a SSH server.
Example Usage
#include <libsshtunnel.h>
// Callback that handles the SSH server's fingerprint.
// For the example, accepts any fingerprint, but normally
// you would check against saved ones etc.
int ssh_fingerprint_check(void *client,
const char *fingerprint,
int fingerprint_len,
const char *host,
int port) {
return 0;
}
// No extended error checking here for the sake of API showoff.
int main () {
// Init crypto backend, has to be called only once.
ssh_tunnel_init();
// Open a tunnel. This one uses password auth, there also is a variant using the private key.
ssh_tunnel_t *t = ssh_tunnel_open_with_password("ssh.server.net", // Hostname of SSH server
"username", // SSH user name
"password", // SSH user's password
"localhost", // Remote service is running directly on SSH server
26000, // Port of remote service
NULL, // You can give an application pointer here that's handed to the callbacks.
ssh_fingerprint_check, // SSH fingerprint check callback
NULL); // Callback for error reporting, can be omitted
if(t) {
// Initial tunnel creation succeeded; you can now let your code connect
// to the local end of the tunnel:
// Your client will get connected to the server running on
// "ssh.server.net", port 26000, as specified above.
my_client_connect("localhost", ssh_tunnel_get_port(t));
// Your other logic here...
}
// Closes the tunnel and frees memory.
ssh_tunnel_close(t);
return 0;
}
Building
libsshtunnel uses CMake, thus it's:
mkdir build
cd build
cmake ..
cmake --build .
License
libsshtunnel is licensed under the BSD 3-Clause License. See COPYING for more information.
Related Skills
node-connect
351.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
110.7kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
351.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
351.4kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
