fatedier / frp

A fast reverse proxy to help you expose a local server behind a NAT or firewall to the internet.
Apache License 2.0
85.34k stars 13.23k forks source link

How can I connect to WSL in my PC? #1436

Closed jiaoruohong closed 4 years ago

jiaoruohong commented 5 years ago

What version of frp are you using (./frpc -v or ./frps -v)? frp_0.29.0_windows_amd64

What operating system and processor architecture are you using (go env)? Windows 64

Configures you used:

  1 [common]                                                                                                                                          
  2 server_addr = myserver.xyz                                                                                                                  
  3 server_port = 7000                                                                                                                                
  4                                                                                                                                                   
  5 [ssh_win_pc]                                                                                                                                      
  6 type = tcp                                                                                                                                        
  7 local_ip = 127.0.0.1                                                                                                                              
  8 local_port = 22                                                                                                                                   
  9 remote_port = 6000                                                                                                                                
 10                                                                                                                                                   
 11 [ssh_ubuntu_pc]                                                                                                                                   
 12 type = tcp                                                                                                                                        
 13 local_ip = 127.0.0.1                                                                                                                              
 14 local_port = 2222                                                                                                                                 
 15 remote_port = 6001                                                                                                                                
 16                                                                                                                                                   
 17 [mosh_ubuntu_pc]                                                                                                                                  
 18 type = udp                                                                                                                                        
 19 local_ip = 127.0.0.1                                                                                                                              
 20 local_port = 60001                                                                                                                                
 21 remote_port = 6002                                                                                                                                
 22                                                                                                                                                   
 23 [rdp_win_pc]                                                                                                                                      
 24 type = tcp                                                                                                                                        
 25 local_ip = 127.0.0.1                                                                                                                              
 26 local_port = 3389                                                                                                                                 
 27 remote_port = 7001

Steps to reproduce the issue:

  1. I use IOS App (Blink shell) to connect my pc. And I have an aliyun server which has an public IP. I opened TCP ports for ssh connections and UDP ports for mosh connections. I run frps on aliyun server, and I run frpc on my windows pc (I don’t run frpc on my WSL).
  2. When I connect my pc (windows) by ssh, there’s no problem.
  3. When I connect my WSL (Ubuntu) by ssh or mosh, Blink shell return me follows:
    
    blink> ssh my_ubuntu_pc
    Socket error: disconnected

blink> mosh my_ubuntu_pc Socket error: disconnected Did not find remote IP address


**Describe the results you received:**

blink> ssh my_ubuntu_pc Socket error: disconnected

blink> mosh my_ubuntu_pc Socket error: disconnected Did not find remote IP address



**Describe the results you expected:**
I just want to connect my WSL (Ubuntu) in my iPad Pro by Blink shell.

**Additional information you deem important (e.g. issue happens only occasionally):**
I don’t think its about ssh-key’s problem, and I can use Blink shell to ssh or mosh to my WSL when my iPad Pro and my PC in a same WiFi environment.

**Can you point out what caused this issue (optional)**
Do I have to run frpc in my WSL (Ubuntu) ?
jiaoruohong commented 5 years ago

After rebootting my PC, restarting sshd and mosh-server, now I can ssh to my WSL. But I still can't mosh to my WSL,

mosh did not make a successful connection to x.x.x.x:6002
Please verify that UDP port 6002 is not firewalled and can reach the server.

(By default, mosh uses a UDP port between 60000 and 61000. The -p option selects a specific UDP port number.

Mosh session finished!
fatedier commented 4 years ago

Check if the frps is listening on udp port 6002.

zhaoruibing commented 4 years ago

Just an idea, try changing [mosh_ubuntu_pc] remote port from 6002 to 60001, matching the local port.

Before this change, I had same error as jiaoruohong, where mosh timed out after 60s, mosh --ssh='ssh -p 6001' --server='mosh-server new -p 60001 -l LANG=en_US.UTF-8' -p 6002 foo_user@myserver.xyz

After changing remote port to 60001, I can mosh to my machine. mosh --ssh='ssh -p 6001' --server='mosh-server new -l LANG=en_US.UTF-8' -p 60001 foo_user@myserver.xyz

My guess is mosh command ignores the server port (60001) whenever there is a -p option (6002).

My setup:

dongyuwei commented 3 weeks ago

我在 https://v2ex.com/t/395885?p=1#r_15289173 提供了比较完整的 mosh over frp 配置。