nobonobo / ssh-p2p Goto Github PK
View Code? Open in Web Editor NEWssh p2p tunneling server and client
License: MIT License
ssh p2p tunneling server and client
License: MIT License
The server was run on VirtualBox Ubuntu 18.04 and openssh-server
is installed on the server. openssh-server
is accessible if connect to it from localhost. The Internet is present on the VirtualBox (connected via NAT adapted) .
The client was run Ubuntu 16.04 host (tried also on 18.04). Here are commands and logs from server:
vbuser@vbuser-VirtualBox:~$ export KEY=22daf66d-46d5-4924-9d92-c4e5e5c9caea
vbuser@vbuser-VirtualBox:~$ ./ssh-p2p server -key=$KEY -dial=127.0.0.1:22
2019/02/22 17:41:05 main.go:194: server started
2019/02/22 17:42:58 main.go:196: info: signaling.ConnectInfo{Source:"8d5d8a69-f12f-437b-b7b8-3e5a2516ba27", SDP:"v=0\r\no=- 990904099 1550850178 IN IP4 0.0.0.0\r\ns=-\r\nt=0 0\r\na=fingerprint:sha-256 22:39:8A:9D:F4:97:37:40:80:35:AE:25:1E:F1:3E:E1:DF:08:F3:39:11:B7:4D:35:A3:8C:05:C7:20:09:EE:C4\r\na=group:BUNDLE data\r\nm=application 9 DTLS/SCTP 5000\r\nc=IN IP4 0.0.0.0\r\na=setup:actpass\r\na=mid:data\r\na=sendrecv\r\na=sctpmap:5000 webrtc-datachannel 1024\r\na=ice-ufrag:aZHQXWUvrKamgiFY\r\na=ice-pwd:MJhSWisrVCpbHyJnmDlYjPLggDzSvxBB\r\na=candidate:foundation 1 udp 29770 10.66.253.222 60995 typ host generation 0\r\na=candidate:foundation 2 udp 2306 10.66.253.222 60995 typ host generation 0\r\na=candidate:foundation 1 udp 22814 192.168.122.1 38529 typ host generation 0\r\na=candidate:foundation 2 udp 35652 192.168.122.1 38529 typ host generation 0\r\na=candidate:foundation 1 udp 31392 172.20.1.1 50703 typ host generation 0\r\na=candidate:foundation 2 udp 3888 172.20.1.1 50703 typ host generation 0\r\na=candidate:foundation 1 udp 26138 172.17.0.1 57581 typ host generation 0\r\na=candidate:foundation 2 udp 2740 172.17.0.1 57581 typ host generation 0\r\na=candidate:foundation 1 udp 5710 172.22.0.1 38818 typ host generation 0\r\na=candidate:foundation 2 udp 11218 172.22.0.1 38818 typ host generation 0\r\na=end-of-candidates\r\na=setup:actpass\r\n"}
could not listen udp fe80::1f99:a47d:f0d3:294d
could not allocate udp6 stun:stun.l.google.com:19302: Failed to create STUN client: dial udp6 [2a00:1450:4010:c01::7f]:19302: connect: network is unreachable
2019/02/22 17:42:58 main.go:209: pc ice state change:Checking
and from the client:
jrybak2312@jrybak2312-Precision-M4700:~/IdeaProjects/ssh-p2p$ export KEY=22daf66d-46d5-4924-9d92-c4e5e5c9caea
jrybak2312@jrybak2312-Precision-M4700:~/IdeaProjects/ssh-p2p$ ./ssh-p2p client -key=$KEY -listen=127.0.0.1:2222
2019/02/22 17:42:24 main.go:165: listen: 127.0.0.1:2222
2019/02/22 17:42:53 main.go:262: client id: 8d5d8a69-f12f-437b-b7b8-3e5a2516ba27
could not listen udp fe80::7879:824b:7b0b:b32a
could not allocate udp4 stun:signaling.irieda.com:19302: Failed to make STUN request: read udp4 10.66.253.222:54093->35.227.187.91:19302: i/o timeout
could not allocate udp6 stun:signaling.irieda.com:19302: Failed to create STUN client: dial udp6: address signaling.irieda.com: no suitable address found
2019/02/22 17:42:58 main.go:295: DataChannel:&{{{0 0} 0 0 0 0} 0xc00000c040 data true <nil> <nil> false 0xc00022e00a low connecting 0 0 0x6a2810 0x6a26d0 0xc000150000 <nil>}
2019/02/22 17:43:00 main.go:300: info: signaling.ConnectInfo{Source:"22daf66d-46d5-4924-9d92-c4e5e5c9caea", SDP:"v=0\r\no=- 133720317 1550850178 IN IP4 0.0.0.0\r\ns=-\r\nt=0 0\r\na=fingerprint:sha-256 ED:BF:6D:35:8C:37:26:0E:D6:90:F3:32:49:AD:B4:25:37:18:D7:5A:98:F3:0C:4D:9E:05:DE:EC:58:81:3C:C1\r\na=group:BUNDLE data\r\nm=application 9 DTLS/SCTP 5000\r\nc=IN IP4 0.0.0.0\r\na=setup:active\r\na=mid:data\r\na=sendrecv\r\na=sctpmap:5000 webrtc-datachannel 1024\r\na=ice-ufrag:PeQGGMKWdmALApqE\r\na=ice-pwd:GmgAtVrXoadYeYabFFOemOnACLjcnPLp\r\na=candidate:foundation 1 udp 45376 10.0.2.15 48415 typ host generation 0\r\na=candidate:foundation 2 udp 37122 10.0.2.15 48415 typ host generation 0\r\na=candidate:foundation 1 udp 36976 93.77.254.210 37193 typ srflx raddr 10.0.2.15 rport 53061 generation 0\r\na=candidate:foundation 2 udp 31328 93.77.254.210 37193 typ srflx raddr 10.0.2.15 rport 53061 generation 0\r\na=end-of-candidates\r\n"}
2019/02/22 17:43:00 main.go:269: pc ice state change:Checking
It is nothing happens, just stuck after the run:
ssh -p 2222 [email protected]
SSH works great
Attempting to use SCP does not.
Failed to push SCTP packet: Failed handling chunk: Failure handling SACK: SACK Cumulative ACK 879487160 is older than ACK point 879487163
Failed to push SCTP packet: Failed handling chunk: Failure handling SACK: SACK Cumulative ACK 879487161 is older than ACK point 879487165
Failed to push SCTP packet: Failed handling chunk: Failure handling SACK: SACK Cumulative ACK 879487162 is older than ACK point 879487165
I thought it was related to this: pion/webrtc#194
But the vendorized dependency has the fix.
Cool Project! I try to use ssh-p2p from China, but Google services is non-accessible from China. Is it possible to use it without Google service. Do you have any suggestion? Thank you.
Server: ubuntu 20.04
Client: Ubuntu 18.04.6 LTS bionic beaver
Error message appears repeatedly at 1-2 second intervals on both client and server.
main.go:108: get failed: invalid character '<' looking for beginning of value
On client side:
ldd ~/go/bin/ssh-p2p
linux-vdso.so.1 (0x00007ffde8791000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fb4c70a8000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fb4c6cb7000)
/lib64/ld-linux-x86-64.so.2 (0x00007fb4c72c7000)
Client side command
~/go/bin/ssh-p2p client -key="$key" -listen=127.0.0.1:2222
Server side command
~/go/bin/ssh-p2p server -key="$key" -dial=127.0.0.1:22
$key has same value on both ends.
ssh -p 2222 127.0.0.1 does not connect through. It just sits there with no messages or prompts. SSH sever is installed on server ed.
client and server are separated by 20 miles and a snow storm. Fortunately, this was just a test.
server side installation:
sudo apt-get install -y golang openssh-server
go get -u github.com/nobonobo/ssh-p2p
~/go/bin/ssh-p2p newkey
key = $(ssh-p2p newkey)
echo $key
~/go/bin/ssh-p2p server -key="$key" -dial=127.0.0.1:22
Key was photographed and entered twice and compared on client system.
Will be good to simplify connection process via one command on client and server.
So auto-generate new key and store it in somewhere like .config/ssh-p2p
and show short instruction for user.
Something like this:
myuser@remotehost$ ssh-p2p server
No stored key found, generated new key: 34d90493-5f6f-4e2b-8932-a8e0b1c8aa27
Key stored in file .config/ssh-p2p/server-key.txt
Use this command on client for connect to this host:
ssh-p2p connect 34d90493-5f6f-4e2b-8932-a8e0b1c8aa27 -u myuser
Waiting for connections. Press Ctrl+C for exit.
And on client side - auto start ssh process after connecting:
myuser2@clienthost$ ssh-p2p connect 34d90493-5f6f-4e2b-8932-a8e0b1c8aa27 -u myuser
2019/06/04 06:54:40 main.go:269: pc ice state change:Checking
2019/06/04 06:54:42 main.go:269: pc ice state change:Connected
2019/06/04 06:54:42 Starting ssh process: ssh -p 2222 127.0.0.1 -u myuser
[email protected]'s password:
myuser@remotehost$ # we are connected!
READMEに追記する
I'm currently trying to do port forwarding of another IP in the host network by using a reverse tunnel. I connected everything like how it is described and executed the command
ssh -L 1234:192.168.1.21:3389 -p 2222 [email protected]
The login is successful and the shell responsive. But by the time I try to connect to it over RDP on my client, the connection crashes with this error on the host side:
Failed to accept data channel: The association is closed
Failed to read from data channel stream closed
2019/07/23 16:13:56 main.go:220: disconnected
This commit changed functions names:
Which cause a compilation error :
src/github.com/nobonobo/ssh-p2p/main.go:197:14: undefined: webrtc.New
src/github.com/nobonobo/ssh-p2p/main.go:263:13: undefined: webrtc.New
Binary was build using the command :
go build -o ssh-p2p
Both server and client were run on the same host(also tried to run the server on VirtualBox and client on the host, but the same result).
Here are commands and logs of the server:
root@jrybak2312-Precision-M4700:/home/jrybak2312/IdeaProjects/ssh-p2p# export KEY=$(./ssh-p2p newkey)
root@jrybak2312-Precision-M4700:/home/jrybak2312/IdeaProjects/ssh-p2p# echo $KEY
f153c7d5-53d1-428c-b1cc-ddd8d4279f52
root@jrybak2312-Precision-M4700:/home/jrybak2312/IdeaProjects/ssh-p2p# ./ssh-p2p server -key=$KEY -dial=127.0.0.1:22
2019/02/20 14:25:42 main.go:194: server started
2019/02/20 14:27:41 main.go:196: info: signaling.ConnectInfo{Source:"5b553f57-3b2c-40bf-b38f-77142df0a1bc", SDP:"v=0\r\no=- 359539736 1550665660 IN IP4 0.0.0.0\r\ns=-\r\nt=0 0\r\na=fingerprint:sha-256 10:4C:10:D8:FB:2E:D2:11:C3:B6:BF:04:5B:0E:B7:6F:F0:B6:69:47:A1:10:9A:A1:D7:C3:38:E6:E0:6F:49:82\r\na=group:BUNDLE data\r\nm=application 9 DTLS/SCTP 5000\r\nc=IN IP4 0.0.0.0\r\na=setup:actpass\r\na=mid:data\r\na=sendrecv\r\na=sctpmap:5000 webrtc-datachannel 1024\r\na=ice-ufrag:wEuTADrzOmWedjTs\r\na=ice-pwd:WPsMLvQklUDvShfZSBkZjGRwcdHGUyHx\r\na=candidate:foundation 1 udp 6428 10.66.253.222 37552 typ host generation 0\r\na=candidate:foundation 2 udp 26194 10.66.253.222 37552 typ host generation 0\r\na=candidate:foundation 1 udp 53800 192.168.122.1 38370 typ host generation 0\r\na=candidate:foundation 2 udp 29288 192.168.122.1 38370 typ host generation 0\r\na=candidate:foundation 1 udp 16940 172.20.1.1 60500 typ host generation 0\r\na=candidate:foundation 2 udp 19468 172.20.1.1 60500 typ host generation 0\r\na=candidate:foundation 1 udp 22982 172.17.0.1 52382 typ host generation 0\r\na=candidate:foundation 2 udp 33162 172.17.0.1 52382 typ host generation 0\r\na=candidate:foundation 1 udp 16654 172.22.0.1 55040 typ host generation 0\r\na=candidate:foundation 2 udp 10978 172.22.0.1 55040 typ host generation 0\r\na=candidate:foundation 1 udp 4668 93.77.254.210 39784 typ srflx raddr 10.66.253.222 rport 39784 generation 0\r\na=candidate:foundation 2 udp 63310 93.77.254.210 39784 typ srflx raddr 10.66.253.222 rport 39784 generation 0\r\na=end-of-candidates\r\na=setup:actpass\r\n"}
could not listen udp fe80::7879:824b:7b0b:b32a
could not listen udp fe80::42:dff:fe70:40e0
could not allocate udp6 stun:stun.l.google.com:19302: Failed to create STUN client: dial udp6 [2a00:1450:4010:c01::7f]:19302: connect: network is unreachable
2019/02/20 14:27:41 main.go:204: ssh dial filed: dial tcp 127.0.0.1:22: connect: connection refused
Here are commands and logs of the client:
root@jrybak2312-Precision-M4700:/home/jrybak2312/IdeaProjects/ssh-p2p# export KEY=f153c7d5-53d1-428c-b1cc-ddd8d4279f52
root@jrybak2312-Precision-M4700:/home/jrybak2312/IdeaProjects/ssh-p2p# ./ssh-p2p client -key=$KEY -listen=127.0.0.1:2222
2019/02/20 14:26:52 main.go:165: listen: 127.0.0.1:2222
2019/02/20 14:27:40 main.go:262: client id: 5b553f57-3b2c-40bf-b38f-77142df0a1bc
could not listen udp fe80::7879:824b:7b0b:b32a
could not listen udp fe80::42:dff:fe70:40e0
could not allocate udp6 stun:stun.l.google.com:19302: Failed to create STUN client: dial udp6 [2a00:1450:4010:c01::7f]:19302: connect: network is unreachable
2019/02/20 14:27:40 main.go:295: DataChannel:&{{{0 0} 0 0 0 0} 0xc000126000 data true <nil> <nil> false 0xc00022208e low connecting 0 0 0x6a2810 0x6a26d0 0xc000124000 <nil>}
i found error while running in folder ssh-p2p
go run main.go server -key="" -dial="127.0.0.1:22"
2017/08/01 11:26:11 Get https://signaling.arukascloud.io/stun: dial tcp: lookup signaling.arukascloud.io on 127.0.0.1:53 no such host
is it correct my command ? or the host is dead ?
because i check in dnsdumpster there is no host
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.