ginuerzh / gost

GO Simple Tunnel - a simple tunnel written in golang
MIT License
16.03k stars 2.49k forks source link

some examples for how to run gost as tunnel. #935

Open woodlyer opened 1 year ago

woodlyer commented 1 year ago

https://github.com/woodlyer/gostExample for more infomation.

./gost -L kcp://:9000/:8083 
./gost -L tcp://127.0.0.1:8083  -F forward+kcp://server_ip:9000

Wish it is helpful for someone.

ehsanecc commented 1 year ago

Hi, I'm trying to connect to Server B through Server A with ssh, basically I can connect to Server B fine with: gost -L=:9050 -F forward+ssh://user@serverb:port but now I want to add Server A in the middle and currently no luck!

Please help! Thanks in advance

woodlyer commented 1 year ago

build a tunnel from A to B for ssh port 22 like this. kcp can be replaced with tls.

# server B
./gost -L kcp://:9000/:22
# server A
./gost -L tcp://:9050   -F forward+kcp://serverB_ip:9000

# ssh client to connect serverB with ssh.
ssh  user@serverA_ip  -p 9050  
ehsanecc commented 1 year ago

Thanks I think I didn't explain exactly what I need, I need a proxy (socks) through ssh protocol. I'm doing like this now:

# this will listen on local port 2222 and redirect connections to server B (through server A)
ssh -L 2222:<serverB_ip>:<serverB_port> <serverA_user>@<serverA_ip>:<serverA_port>

# forwards socks requests to server B (through server A)
gost-linux-armv8-2.11.4 -L=:<local_socks_listen_port> -F forward+ssh://<serverB_user>@localhost:2222

but still, this is a two step process (run ssh then run gost). I wonder if it can be run in just one gost command (chained). And also, I've tried chaining -F (forward+)ssh:// combinations aleady and get ssh connection failed error.

woodlyer commented 1 year ago

I' m sorry, gost is a very powerful tool. I just make some tunnel example and proxy example.
I'm not very familiar with chains.

orxvan commented 1 year ago

build a tunnel from A to B for ssh port 22 like this. kcp can be replaced with tls.

# server B
./gost -L kcp://:9000/:22
# server A
./gost -L tcp://:9050   -F forward+kcp://serverB_ip:9000

# ssh client to connect serverB with ssh.
ssh  user@serverA_ip  -p 9050  

When I type code like this,the ssh -vvv says

debug1: Local version string SSH-2.0-OpenSSH_7.4
ssh_exchange_identification: Connection closed by remote host

the gost log seems the server A didn't send kcp request to server B, I'm confused for a long time

woodlyer commented 1 year ago

This cmd is ok. Please check udp is not blocked. for example: use kcp on tcp or tls.

./gost -L kcp://:9000/:22?tcp=true
./gost -L tcp://:9050   -F forward+kcp://serverB_ip:9000?tcp=true
orxvan commented 1 year ago

This cmd is ok. Please check udp is not blocked. for example: use kcp on tcp or tls.

./gost -L kcp://:9000/:22?tcp=true
./gost -L tcp://:9050   -F forward+kcp://serverB_ip:9000?tcp=true

Thx