[GH-ISSUE #2064] 127.0.0.1自联测试,提示Connection closed by remote host,不知该如何解决 #1639

Closed
opened 2026-05-05 13:02:57 -06:00 by gitea-mirror · 5 comments
Owner

Originally created by @EacoChen on GitHub (Nov 7, 2020).
Original GitHub issue: https://github.com/fatedier/frp/issues/2064

Issue is only used for submiting bug report and documents typo. If there are same issues or answers can be found in documents, we will close it directly.

Use the commands below to provide key information from your environment:
You do NOT have to include this information if this is a FEATURE REQUEST

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

  • In the same client but different terminal, like terminal1,terminal2 and 3

frpc: 0.34.2
frps: 0.34.2

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

GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/linux1/.cache/go-build"
GOENV="/home/linux1/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/linux1/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/linux1/go"
GOPRIVATE=""
GOPROXY="https://goproxy.io"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/linux1/Downloads/frp/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build738668228=/tmp/go-build -gno-record-gcc-switches"

Configures you used:

cat ./conf/frpc.ini

[common]
server_addr = 127.0.0.1
server_port = 7000

[cugb_ssh]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 8232

cat ./conf/frps.ini

[common]
bind_port = 7000

Steps to reproduce the issue:

  1. ./bin/frps -c ./conf/frps.ini
  2. ./bin/frpc -c ./conf/frpc.ini
  3. ssh -p8232 linux1@127.0.0.1

Describe the results you received:

  • In the terminal using as server:

2020/11/07 18:10:44 [I] [service.go:190] frps tcp listen on 0.0.0.0:7000
2020/11/07 18:10:44 [I] [root.go:212] start frps success

2020/11/07 18:10:49 [I] [service.go:444] [6e0d17c79659414b] client login info: ip [127.0.0.1:49352] version [0.34.2] hostname [] os [linux] arch [amd64]
2020/11/07 18:10:49 [I] [tcp.go:63] [6e0d17c79659414b] [cugb_ssh] tcp proxy listen port [8232]
2020/11/07 18:10:49 [I] [control.go:446] [6e0d17c79659414b] new proxy [cugb_ssh] success

2020/11/07 18:10:58 [I] [proxy.go:103] [6e0d17c79659414b] [cugb_ssh] get a new work connection: [127.0.0.1:49352]

  • In the terminal using as client:

2020/11/07 18:10:49 [I] [service.go:288] [6e0d17c79659414b] login to server success, get run id [6e0d17c79659414b], server udp port [0]
2020/11/07 18:10:49 [I] [proxy_manager.go:144] [6e0d17c79659414b] proxy added: [cugb_ssh]
2020/11/07 18:10:49 [I] [control.go:180] [6e0d17c79659414b] [cugb_ssh] start proxy success

2020/11/07 18:10:58 [E] [proxy.go:793] [6e0d17c79659414b] [cugb_ssh] connect to local service [127.0.0.1:22] error: dial tcp 127.0.0.1:22: connect: connection refused

  • In the terminal using as ssh

linux1 @ linux1 in ~ [18:00:50] C:255
$ ssh -p8232 root@127.0.0.1
ssh_exchange_identification: Connection closed by remote host

Describe the results you expected:

*The results is from the True server test

$ ssh -p8232 root@127.0.0.1
The authenticity of host '[127.0.0.1]:8232 ([127.0.0.1]:8232)' can't be established.
ECDSA key fingerprint is SHA256:j+********************************************.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '[127.0.0.1]:8232' (ECDSA) to the list of known hosts.
root@127.0.0.1's password:

Welcome to Alibaba Cloud Elastic Compute Service !

Activate the web console with: systemctl enable --now cockpit.socket

Last failed login: Sat Nov 7 17:47:11 CST 2020 from 127.0.0.1 on ssh:notty
There was 1 failed login attempt since the last successful login.
Last login: Sat Nov 7 17:43:39 2020 from ..***.**6

Additional information you deem important (e.g. issue happens only occasionally):

always happen

In ssh terminal, I also tried:
curl 127.0.0.1:8232
but the result is :

curl: (52) Empty reply from server

cilent terminal give the same log info as mentioned above.

Can you point out what caused this issue (optional)

maybe the firewall?
The client in office is use the Wired static IP, configured by IT department.

Originally created by @EacoChen on GitHub (Nov 7, 2020). Original GitHub issue: https://github.com/fatedier/frp/issues/2064 Issue is only used for submiting bug report and documents typo. If there are same issues or answers can be found in documents, we will close it directly. Use the commands below to provide key information from your environment: You do NOT have to include this information if this is a FEATURE REQUEST **What version of frp are you using (./frpc -v or ./frps -v)?** * In the same client but different terminal, like terminal1,terminal2 and 3 > frpc: 0.34.2 > frps: 0.34.2 **What operating system and processor architecture are you using (`go env`)?** > GO111MODULE="on" > GOARCH="amd64" > GOBIN="" > GOCACHE="/home/linux1/.cache/go-build" > GOENV="/home/linux1/.config/go/env" > GOEXE="" > GOFLAGS="" > GOHOSTARCH="amd64" > GOHOSTOS="linux" > GOINSECURE="" > GOMODCACHE="/home/linux1/go/pkg/mod" > GONOPROXY="" > GONOSUMDB="" > GOOS="linux" > GOPATH="/home/linux1/go" > GOPRIVATE="" > GOPROXY="https://goproxy.io" > GOROOT="/usr/local/go" > GOSUMDB="sum.golang.org" > GOTMPDIR="" > GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64" > GCCGO="gccgo" > AR="ar" > CC="gcc" > CXX="g++" > CGO_ENABLED="1" > GOMOD="/home/linux1/Downloads/frp/go.mod" > CGO_CFLAGS="-g -O2" > CGO_CPPFLAGS="" > CGO_CXXFLAGS="-g -O2" > CGO_FFLAGS="-g -O2" > CGO_LDFLAGS="-g -O2" > PKG_CONFIG="pkg-config" > GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build738668228=/tmp/go-build -gno-record-gcc-switches" **Configures you used:** `cat ./conf/frpc.ini` > [common] > server_addr = 127.0.0.1 > server_port = 7000 > > [cugb_ssh] > type = tcp > local_ip = 127.0.0.1 > local_port = 22 > remote_port = 8232 `cat ./conf/frps.ini` > [common] > bind_port = 7000 **Steps to reproduce the issue:** 1. `./bin/frps -c ./conf/frps.ini` 2. `./bin/frpc -c ./conf/frpc.ini` 3. `ssh -p8232 linux1@127.0.0.1` **Describe the results you received:** * In the terminal using as **server**: > 2020/11/07 18:10:44 [I] [service.go:190] frps tcp listen on 0.0.0.0:7000 > 2020/11/07 18:10:44 [I] [root.go:212] start frps success > > 2020/11/07 18:10:49 [I] [service.go:444] [6e0d17c79659414b] client login info: ip [127.0.0.1:49352] version [0.34.2] hostname [] os [linux] arch [amd64] > 2020/11/07 18:10:49 [I] [tcp.go:63] [6e0d17c79659414b] [cugb_ssh] tcp proxy listen port [8232] > 2020/11/07 18:10:49 [I] [control.go:446] [6e0d17c79659414b] new proxy [cugb_ssh] success > 2020/11/07 18:10:58 [I] [proxy.go:103] [6e0d17c79659414b] [cugb_ssh] get a new work connection: [127.0.0.1:49352] * In the terminal using as **client**: > 2020/11/07 18:10:49 [I] [service.go:288] [6e0d17c79659414b] login to server success, get run id [6e0d17c79659414b], server udp port [0] > 2020/11/07 18:10:49 [I] [proxy_manager.go:144] [6e0d17c79659414b] proxy added: [cugb_ssh] > 2020/11/07 18:10:49 [I] [control.go:180] [6e0d17c79659414b] [cugb_ssh] start proxy success > 2020/11/07 18:10:58 [E] [proxy.go:793] [6e0d17c79659414b] [cugb_ssh] **connect to local service [127.0.0.1:22] error: dial tcp 127.0.0.1:22: connect: connection refused** * In the terminal using as **ssh** > linux1 @ linux1 in ~ [18:00:50] C:255 > $ ssh -p8232 root@127.0.0.1 > **ssh_exchange_identification: Connection closed by remote host** **Describe the results you expected:** *The results is from the True server test > $ ssh -p8232 root@127.0.0.1 > The authenticity of host '[127.0.0.1]:8232 ([127.0.0.1]:8232)' can't be established. > ECDSA key fingerprint is SHA256:j+********************************************. > Are you sure you want to continue connecting (yes/no/[fingerprint])? _yes_ > Warning: Permanently added '[127.0.0.1]:8232' (ECDSA) to the list of known hosts. > root@127.0.0.1's password: > > Welcome to Alibaba Cloud Elastic Compute Service ! > > Activate the web console with: systemctl enable --now cockpit.socket > > Last failed login: Sat Nov 7 17:47:11 CST 2020 from 127.0.0.1 on ssh:notty > There was 1 failed login attempt since the last successful login. > Last login: Sat Nov 7 17:43:39 2020 from ***.***.***.**6 **Additional information you deem important (e.g. issue happens only occasionally):** # always happen In ssh terminal, I also tried: `curl 127.0.0.1:8232 ` but the result is : > curl: (52) Empty reply from server cilent terminal give the same log info as mentioned above. **Can you point out what caused this issue (optional)** **maybe the firewall? The client in office is use the Wired static IP, configured by IT department.**
Author
Owner

@Becods commented on GitHub (Nov 7, 2020):

经测试无发现问题
请确认是否有其他因素造成
请使用排除法多次测试

curl 127.0.0.1:8232
curl: (1) Received HTTP/0.9 when not allowed
2020/11/07 11:54:39 [I] [service.go:190] frps tcp listen on 0.0.0.0:7000
2020/11/07 11:54:39 [I] [root.go:212] start frps success
2020/11/07 11:54:48 [I] [service.go:444] [75da2cdad4ce0ac9] client login info: ip [127.0.0.1:32822] version [0.34.2] hostname [] os [linux] arch [amd64]
2020/11/07 11:54:48 [I] [tcp.go:63] [75da2cdad4ce0ac9] [cugb_ssh] tcp proxy listen port [8232]
2020/11/07 11:54:48 [I] [control.go:446] [75da2cdad4ce0ac9] new proxy [cugb_ssh] success
2020/11/07 11:55:06 [I] [proxy.go:103] [75da2cdad4ce0ac9] [cugb_ssh] get a new work connection: [127.0.0.1:32822]
2020/11/07 11:54:48 [I] [service.go:288] [75da2cdad4ce0ac9] login to server success, get run id [75da2cdad4ce0ac9], server udp port [0]
2020/11/07 11:54:48 [I] [proxy_manager.go:144] [75da2cdad4ce0ac9] proxy added: [cugb_ssh]
2020/11/07 11:54:48 [I] [control.go:180] [75da2cdad4ce0ac9] [cugb_ssh] start proxy success
OpenSSH_8.2p1 Ubuntu-4ubuntu0.1, OpenSSL 1.1.1f  31 Mar 2020
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug2: resolve_canonicalize: hostname 127.0.0.1 is address
debug2: ssh_connect_direct
----hide----
debug3: authmethod_is_enabled password
debug1: Next authentication method: password
root@127.0.0.1's password:
<!-- gh-comment-id:723437430 --> @Becods commented on GitHub (Nov 7, 2020): 经测试无发现问题 请确认是否有其他因素造成 请使用排除法多次测试 ``` curl 127.0.0.1:8232 curl: (1) Received HTTP/0.9 when not allowed ``` ``` 2020/11/07 11:54:39 [I] [service.go:190] frps tcp listen on 0.0.0.0:7000 2020/11/07 11:54:39 [I] [root.go:212] start frps success 2020/11/07 11:54:48 [I] [service.go:444] [75da2cdad4ce0ac9] client login info: ip [127.0.0.1:32822] version [0.34.2] hostname [] os [linux] arch [amd64] 2020/11/07 11:54:48 [I] [tcp.go:63] [75da2cdad4ce0ac9] [cugb_ssh] tcp proxy listen port [8232] 2020/11/07 11:54:48 [I] [control.go:446] [75da2cdad4ce0ac9] new proxy [cugb_ssh] success 2020/11/07 11:55:06 [I] [proxy.go:103] [75da2cdad4ce0ac9] [cugb_ssh] get a new work connection: [127.0.0.1:32822] ``` ``` 2020/11/07 11:54:48 [I] [service.go:288] [75da2cdad4ce0ac9] login to server success, get run id [75da2cdad4ce0ac9], server udp port [0] 2020/11/07 11:54:48 [I] [proxy_manager.go:144] [75da2cdad4ce0ac9] proxy added: [cugb_ssh] 2020/11/07 11:54:48 [I] [control.go:180] [75da2cdad4ce0ac9] [cugb_ssh] start proxy success ``` ``` OpenSSH_8.2p1 Ubuntu-4ubuntu0.1, OpenSSL 1.1.1f 31 Mar 2020 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files debug1: /etc/ssh/ssh_config line 21: Applying options for * debug2: resolve_canonicalize: hostname 127.0.0.1 is address debug2: ssh_connect_direct ----hide---- debug3: authmethod_is_enabled password debug1: Next authentication method: password root@127.0.0.1's password: ```
Author
Owner

@fatedier commented on GitHub (Nov 8, 2020):

@EacoChen Try ssh root@127.0.0.1 , does it returns the same error?

<!-- gh-comment-id:723525115 --> @fatedier commented on GitHub (Nov 8, 2020): @EacoChen Try `ssh root@127.0.0.1` , does it returns the same error?
Author
Owner

@EacoChen commented on GitHub (Nov 8, 2020):

@EacoChen Try ssh root@127.0.0.1 , does it returns the same error?

Thank you for your reply the results like this:

linux1 @ linux1 in ~ [11:48:49] C:130

$ ssh root@127.0.0.1
ssh: connect to host 127.0.0.1 port 22: Connection refused

<!-- gh-comment-id:723526955 --> @EacoChen commented on GitHub (Nov 8, 2020): > @EacoChen Try `ssh root@127.0.0.1` , does it returns the same error? Thank you for your reply the results like this: > # linux1 @ linux1 in ~ [11:48:49] C:130 > $ ssh root@127.0.0.1 > ssh: connect to host 127.0.0.1 port 22: Connection refused
Author
Owner

@fatedier commented on GitHub (Nov 8, 2020):

@EacoChen Your sshd server may not started or it listen on another port rather than 22.

<!-- gh-comment-id:723527337 --> @fatedier commented on GitHub (Nov 8, 2020): @EacoChen Your sshd server may not started or it listen on another port rather than 22.
Author
Owner

@EacoChen commented on GitHub (Nov 8, 2020):

@fatedier
check if port 22 occupied
lsof -i:22

there are no results.

I test openssh_server
sudo systemctl status ssh

● sshd.service
Loaded: not-found (Reason: No such file or directory)
Active: inactive (dead)

so I updated apt sudo apt update && sudo apt upgrade, and install the sshd sudo apt install openssh-server

Run and check the installation

sudo systemctl status ssh

Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enab
Active: active (running) since 日 2020-11-08 13:04:10 CST; 5min ago

sshd worked.

ssh check
ssh root@127.0.0.1

The authenticity of host '127.0.0.1 (127.0.0.1)' can't be established.
ECDSA key fingerprint is SHA256:
Are you sure you want to continue connecting (yes/no)? yes
worked

client check
ssh -p8232 linux1@127.0.0.1

linux1@127.0.0.1's password:
Welcome to Ubuntu 16.04.7 LTS (GNU/Linux 4.15.0-122-generic x86_64)
worked

Truly frp

vim ./conf/frpc.ini
[common]
server_addr = x.x.x.x
server_port = 7000

[cugb_ssh]
type = tcp
local_ip = 192.168.134.13
local_port = 22
remote_port = 8232

mobaxterm:
ssh -p8232 linux1@x.x.x.x

linux1@x.x.x.x 's password:

worked! Thank you so much!

<!-- gh-comment-id:723534895 --> @EacoChen commented on GitHub (Nov 8, 2020): @fatedier **check if port 22 occupied** `lsof -i:22` there are no results. I test openssh_server `sudo systemctl status ssh` > ● sshd.service > Loaded: not-found (Reason: No such file or directory) > Active: inactive (dead) so I updated apt `sudo apt update && sudo apt upgrade`, and install the sshd `sudo apt install openssh-server` **Run and check the installation** `sudo systemctl status ssh` > Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enab > Active: active (running) since 日 2020-11-08 13:04:10 CST; 5min ago **sshd worked.** **ssh check** `ssh root@127.0.0.1` > The authenticity of host '127.0.0.1 (127.0.0.1)' can't be established. > ECDSA key fingerprint is SHA256: > Are you sure you want to continue connecting (yes/no)? yes worked **client check** `ssh -p8232 linux1@127.0.0.1` > linux1@127.0.0.1's password: > Welcome to Ubuntu 16.04.7 LTS (GNU/Linux 4.15.0-122-generic x86_64) worked **Truly frp** > `vim ./conf/frpc.ini` > [common] > server_addr = x.x.x.x > server_port = 7000 > > [cugb_ssh] > type = tcp > local_ip = 192.168.134.13 > local_port = 22 > remote_port = 8232 **mobaxterm:** `ssh -p8232 linux1@x.x.x.x` > linux1@x.x.x.x 's password: **worked! Thank you so much!**
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/frp#1639
No description provided.