marianafranco / libssh2-tunnel-example Goto Github PK
View Code? Open in Web Editor NEWExample of permanent SSH tunnel using libssh2
License: MIT License
Example of permanent SSH tunnel using libssh2
License: MIT License
Hi,
Have you tried to make this multiuser so you can spin up several SSH sessions back to the original server?
Right now if you try to do: ssh localhost -p 4000
twice it won't work.
I've tried to create a thread right after libssh2_channel_forward_accept
so forward_tunnel
is handled by treads independently. The problem is that since libssh2_session_set_blocking
gets the argument session
which is common among threads there are block problems and it doesn't work.
Any help here?
Btw, great work with it! ;)
Hi,
libssh2_userauth_publickey_fromfile (sess, user, psrv_key.pub, psrv_key.priv, 0) and or
ibssh2_userauth_publickey_fromfile_ex and or
ibssh2_userauth_publickey_frommemory all fails
with -18. while the at the shell the: ssh -i ./psrv_key.priv user@server works fine.
FYI, We are using this example to port ssh tunneling to vala
https://gitlab.gnome.org/albfan/ssh-vala-examples/issues/1
It could be use in sequeler once completed Alecaddd/sequeler#33 (comment)
Thank you a lot for this example, it may be very useful for me, but I get error when try to compile.
I get the next output after make command:
gcc -O3 -Wall -std=c89 -o libssh2-tunnel-example -lssh2 libssh2-tunnel-example.c
libssh2-tunnel-example.c: In function ‘main’:
libssh2-tunnel-example.c:238:40: warning: implicit declaration of function ‘strcasecmp’; did you mean ‘strncmp’? [-Wimplicit-function-declaration]
if ((auth & AUTH_PASSWORD) && !strcasecmp(argv[8], "-p"))
^~~~~~~~~~
strncmp
/tmp/ccStiW1D.o: In function `forward_tunnel':
libssh2-tunnel-example.c:(.text+0x10b): undefined reference to `libssh2_session_set_blocking'
libssh2-tunnel-example.c:(.text+0x1da): undefined reference to `libssh2_channel_read_ex'
libssh2-tunnel-example.c:(.text+0x27d): undefined reference to `libssh2_session_set_blocking'
libssh2-tunnel-example.c:(.text+0x2b5): undefined reference to `libssh2_channel_eof'
libssh2-tunnel-example.c:(.text+0x33b): undefined reference to `libssh2_channel_write_ex'
/tmp/ccStiW1D.o: In function `main':
libssh2-tunnel-example.c:(.text.startup+0xb3): undefined reference to `libssh2_init'
libssh2-tunnel-example.c:(.text.startup+0x134): undefined reference to `libssh2_session_init_ex'
libssh2-tunnel-example.c:(.text.startup+0x14c): undefined reference to `libssh2_session_handshake'
libssh2-tunnel-example.c:(.text.startup+0x168): undefined reference to `libssh2_hostkey_hash'
libssh2-tunnel-example.c:(.text.startup+0x1ef): undefined reference to `libssh2_userauth_list'
libssh2-tunnel-example.c:(.text.startup+0x2b9): undefined reference to `libssh2_userauth_publickey_fromfile_ex'
libssh2-tunnel-example.c:(.text.startup+0x2f6): undefined reference to `libssh2_session_disconnect_ex'
libssh2-tunnel-example.c:(.text.startup+0x2fe): undefined reference to `libssh2_session_free'
libssh2-tunnel-example.c:(.text.startup+0x30c): undefined reference to `libssh2_exit'
libssh2-tunnel-example.c:(.text.startup+0x3c4): undefined reference to `libssh2_userauth_password_ex'
libssh2-tunnel-example.c:(.text.startup+0x416): undefined reference to `libssh2_channel_forward_listen_ex'
libssh2-tunnel-example.c:(.text.startup+0x46f): undefined reference to `libssh2_channel_free'
libssh2-tunnel-example.c:(.text.startup+0x48d): undefined reference to `libssh2_channel_forward_accept'
libssh2-tunnel-example.c:(.text.startup+0x4b7): undefined reference to `libssh2_channel_forward_cancel'
collect2: error: ld returned 1 exit status
Makefile:6: recipe for target 'example' failed
make: *** [example] Error 1
I have ubuntu 18.04.
Info about libssh installed:
ii libssh-4:amd64 0.8.020170825.94fa1e38-1ubuntu0.2 amd64 tiny C SSH library (OpenSSL flavor)20170825.94fa1e38-1ubuntu0.2 amd64 tiny C SSH library (gcrypt flavor)
ii libssh-gcrypt-4:amd64 0.8.0
ii libssh2-1:amd64 1.8.0-1 amd64 SSH2 client-side library
ii libssh2-1-dev:amd64 1.8.0-1 amd64 SSH2 client-side library (development headers)
ii php-ssh2 1.1.2+0.13-3+ubuntu18.04.1+deb.sury.org+10 amd64 Bindings for the libssh2 library
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.