Can you telnet to ssh?

Ba7a7chy picture Ba7a7chy · Jul 18, 2012 · Viewed 58.1k times · Source

I know you can telnet and negotiate with HTTP server by using HTTP protocol standards - for example:

telnet google.com 80
Trying 173.194.70.139...
Connected to google.com.
Escape character is '^]'.
GET / HTTP.1.1
HOST: my.com

and I get in response:

HTTP/1.0 400 Bad Request
Content-Type: text/html; charset=UTF-8
Content-Length: 925
Date: Wed, 18 Jul 2012 19:17:26 GMT
Server: GFE/2.0

but my question is could I do the same with the SSH protocol?

Answer

dwerner picture dwerner · Jul 18, 2012

Try hitting an SSH server with telnet on port 22. You get the first message, but nothing else that's useful. Just a "Protocol Mismatch" and the connection closes.

A telnet client is useful as a tool in this way because it uses a plain-text protocol. You can hit whatever port is using a different plain-text protocol and decode it in your head, as with HTTP. SSH encrypts everything, so using telnet to connect to an SSH server would prove a little hard to read with the naked eye.

telnet yoursshserver 22
Trying 50.112.5.74...
Connected to yoursshserver.
Escape character is '^]'.
SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1
something I typed
Protocol mismatch.
Connection closed by foreign host.