3

When I wanna use VScode remote SSH to my server, the following error is prompted:

... ... kex_exchange_identification: banner line contains invalid characters ... ...

In the beginning, I thought it's an error of my VSCode, but I tried the simplest SSH command in PowerShell, it still happened.

Here is some log:

(base) PS C:\Users\37097> ssh wsco@114.213.208.99 -p 1260 -v                                           OpenSSH_8.2p1, OpenSSL 1.1.1f  31 Mar 2020
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to 114.213.208.99 [114.213.208.99] port 1260.
debug1: Connection established.
debug1: identity file /c/Users/37097/.ssh/id_rsa type -1
debug1: identity file /c/Users/37097/.ssh/id_rsa-cert type -1
debug1: identity file /c/Users/37097/.ssh/id_dsa type -1
debug1: identity file /c/Users/37097/.ssh/id_dsa-cert type -1
debug1: identity file /c/Users/37097/.ssh/id_ecdsa type -1
debug1: identity file /c/Users/37097/.ssh/id_ecdsa-cert type -1
debug1: identity file /c/Users/37097/.ssh/id_ecdsa_sk type -1
debug1: identity file /c/Users/37097/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /c/Users/37097/.ssh/id_ed25519 type -1
debug1: identity file /c/Users/37097/.ssh/id_ed25519-cert type -1
debug1: identity file /c/Users/37097/.ssh/id_ed25519_sk type -1
debug1: identity file /c/Users/37097/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /c/Users/37097/.ssh/id_xmss type -1
debug1: identity file /c/Users/37097/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.2
kex_exchange_identification: banner line contains invalid characters

I tried it even in another ubuntu machine, but have the same problem.

And I tried to google it for few days, but none of it can solve my problem.

LuYi
  • 31
  • 1
  • 1
  • 2
  • 1
    It's likely that port doesn't contain a real SSH server and you're finding some other server instead. – bk2204 Mar 18 '21 at 16:26
  • 1
    @bk2204 God, it's really a stupid MISTAKE I made! This port is my 3389 port, I check my server's SSH port and find that I did type the wrong port, you are absolutely right! Thanks for your answer. – LuYi Mar 19 '21 at 06:44

3 Answers3

9

i see this is without reply, hope you could fix it meanwhile.

For anyone else searching for

kex_exchange_identification: banner line contains invalid characters

note that ssh reports this error when connecting to a webserver (https) by mistake instead of a sshd.

Check that sshd is listening on the host/port your are connecting to, e.g. using netstat -anp

ndu
  • 111
  • 1
  • 4
4

When an SSH client connects to an SSH server, the SSH server process begins by sending a version string to the client in cleartext. You can see it by using "nc":

$ nc localhost 22
SSH-2.0-OpenSSH_8.6

"kex_exchange_identification" means the client has just connected to the server and is waiting to receive this version string. The error "banner line contains invalid characters" means the client received something from the server that wasn't a valid SSH version string.

As a practical matter, the problem is likely to be that the SSH client connected to something that's not an SSH server. As noted in the other answer, connecting to an HTTPS server with an SSH client will produce this error:

$ ssh -p https google.com
kex_exchange_identification: banner line contains invalid characters

The root cause could be one of three things:

  1. The SSH client connected to the wrong hostname/IP address and/or port.
  2. The service isn't supposed to be accessed through an SSH client.
  3. Something is misconfigured or malfunctioning on the server.
Kenster
  • 23,465
  • 21
  • 80
  • 106
-1

In my case, I just first execute: git pull, then execute git push, then everything got ok.

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Apr 20 '23 at 07:01