'ngorkd ssh client Error: key_exchange_identification: Connection closed by remote host

I am trying to setup my own ngrok server on EC2 and trying to tunnel a ssh connection on another machine on which ngrok client is running.

How to run your own ngrokd server

https://github.com/Launch-with-1-Click/aws-ngrok

Server

sudo ngrokd -tlsKey=server.key -tlsCrt=server.crt -domain="example.com" -httpAddr=":8880" 

Client Side

server_addr: example.com:4443
trust_host_root_certs: false 
tunnels:
  test:
    proto:
      tcp: 22

$./bin/ngrok -config=cf.yml -log=ngrok.log start test

Tunnel Status                Online
Forwarding                    tcp://example.com:39695 - 127.0.0.1:22 

But When connected ssh client from another machine

ssh  ubuntu@[IP of example.com] -p 39695
kex_exchange_identification: Connection closed by remote host
Connection closed by [IP] port 39695                   

Log at server

[05:55:09 UTC 2022/02/14] [INFO] (ngrok/log.(*PrefixLogger).Info:83) [pub:37dfdd2b] [tcp://example.com:36683] New connection from XXX.XX.127.107:52356
[05:55:09 UTC 2022/02/14] [INFO] (ngrok/log.(*PrefixLogger).Info:83)  Got proxy connection pxy:42de6dda
[05:55:09 UTC 2022/02/14] [DEBG] (ngrok/log.(*PrefixLogger).Debug:79) [pxy:42de6dda] [bdb21c9c9a5c5875a5d7d2e8fb5a930b] [tcp://example.com:36683] Writing message: {"Type":"StartProxy","Payload":{"Url":"tcp://example.com:36683","ClientAddr":"XXX.XX.127.107:52356"}}
[05:55:09 UTC 2022/02/14] [WARN] (ngrok/log.(*PrefixLogger).Warn:87) [pxy:42de6dda] [bdb21c9c9a5c5875a5d7d2e8fb5a930b] [tcp://example.com:36683] Failed to write StartProxyMessage: write tcp 172.31.38.231:4443->XXX.XX.127.107:40774: i/o timeout, attempt 0
[05:55:09 UTC 2022/02/14] [DEBG] (ngrok/log.(*PrefixLogger).Debug:79) [ctl:51136f2e] [bdb21c9c9a5c5875a5d7d2e8fb5a930b] No proxy in pool, requesting proxy from control . . .
[05:55:09 UTC 2022/02/14] [DEBG] (ngrok/log.(*PrefixLogger).Debug:79) [ctl:51136f2e] [bdb21c9c9a5c5875a5d7d2e8fb5a930b] Writing message: {"Type":"ReqProxy","Payload":{}}
[05:55:09 UTC 2022/02/14] [INFO] (ngrok/log.(*PrefixLogger).Info:83) [tun:1a5638bf] New connection from XXX.XX.127.107:40784
[05:55:09 UTC 2022/02/14] [DEBG] (ngrok/log.(*PrefixLogger).Debug:79) [tun:1a5638bf] Waiting to read message
[05:55:09 UTC 2022/02/14] [DEBG] (ngrok/log.(*PrefixLogger).Debug:79) [tun:1a5638bf] Reading message with length: 77
[05:55:09 UTC 2022/02/14] [DEBG] (ngrok/log.(*PrefixLogger).Debug:79) [tun:1a5638bf] Read message {"Type":"RegProxy","Payload":{"ClientId":"bdb21c9c9a5c5875a5d7d2e8fb5a930b"}}
[05:55:09 UTC 2022/02/14] [INFO] (ngrok/log.(*PrefixLogger).Info:83) [pxy:1a5638bf] Renamed connection tun:1a5638bf
[05:55:09 UTC 2022/02/14] [INFO] (ngrok/log.(*PrefixLogger).Info:83) [pxy:1a5638bf] Registering new proxy for bdb21c9c9a5c5875a5d7d2e8fb5a930b
[05:55:09 UTC 2022/02/14] [INFO] (ngrok/log.(*PrefixLogger).Info:83) [pxy:1a5638bf] [bdb21c9c9a5c5875a5d7d2e8fb5a930b] Registered
[05:55:09 UTC 2022/02/14] [INFO] (ngrok/log.(*PrefixLogger).Info:83)  Got proxy connection pxy:1a5638bf
[05:55:09 UTC 2022/02/14] [DEBG] (ngrok/log.(*PrefixLogger).Debug:79) [pxy:1a5638bf] [bdb21c9c9a5c5875a5d7d2e8fb5a930b] [tcp://example.com:36683] Writing message: {"Type":"StartProxy","Payload":{"Url":"tcp://example.com:36683","ClientAddr":"XXX.XX.127.107:52356"}}
[05:55:09 UTC 2022/02/14] [INFO] (ngrok/log.(*PrefixLogger).Info:83) [pub:37dfdd2b] [tcp://example.com:36683] Joined with connection pxy:1a5638bf
[05:55:09 UTC 2022/02/14] [DEBG] (ngrok/log.(*PrefixLogger).Debug:79) [ctl:51136f2e] [bdb21c9c9a5c5875a5d7d2e8fb5a930b] Writing message: {"Type":"ReqProxy","Payload":{}}
[05:55:10 UTC 2022/02/14] [DEBG] (ngrok/log.(*PrefixLogger).Debug:79) [pxy:1a5638bf] [bdb21c9c9a5c5875a5d7d2e8fb5a930b] [tcp://example.com:36683] Copied 0 bytes to pub:37dfdd2b
[05:55:10 UTC 2022/02/14] [DEBG] (ngrok/log.(*PrefixLogger).Debug:79) [pxy:1a5638bf] [bdb21c9c9a5c5875a5d7d2e8fb5a930b] [tcp://example.com:36683] Closing
[05:55:10 UTC 2022/02/14] [WARN] (ngrok/log.(*PrefixLogger).Warn:87) [pub:37dfdd2b] [tcp://example.com:36683] Copied 41 bytes to pxy:1a5638bf before failing with error read tcp 172.31.38.231:36683->XXX.XX.127.107:52356: use of closed network connection
[05:55:10 UTC 2022/02/14] [DEBG] (ngrok/log.(*PrefixLogger).Debug:79) [pub:37dfdd2b] [tcp://example.com:36683] Closing

What am I missing. Need Help



Solution 1:[1]

Install OpenSSH server on Linux to prevent port 22 connection failed

 sudo apt install openssh-server

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1