How To Check SSH Port Status

Check SSH port 22 with telnet Check SSH port 22 with telnet

When you’re configuring new SSH server, it’s possible that connection won’t work right away. That’s when it will be useful for you to know how to check SSH port status.

Use telnet to check SSH port

The easiest approach has traditionally been to use telnet command. It’s also a more universal way of checking SSH port because telnet is usually found in Windows operating system. In fact, you can check any port using telnet.

INTERESTING: Since telnet is an clear text protocol (no encryption), it’s being phased out so it’s quite possible that you won’t find telnet command installed by default in your Linux/Unix system or even modern Windows or MacOS based desktop.

Provided telnet is installed (yum install telnet in CentOS/RedHat/Fedora Linux, for example) though, here’s how you can check SSH port on remote server:

[email protected]:~ $ telnet vps1.unixtutorial.org 22
Trying 51.15.230.209...
Connected to vps1.unixtutorial.org.
Escape character is '^]'.
SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.8
^]^C^]

If you can see the SSH version information as highlighted above, the SSH port is open and SSH server is functioning properly.

If port 22 is open but SSH server is not listening on it, you’ll get an error like this:

[email protected]:~ $ telnet vps1.unixtutorial.org 22
Trying 163.172.34.149...
telnet: connect to address 163.172.34.149: Connection refused
Verbose ssh command output to check port

My default way of checking remote connectivity is to use ssh command to initiate client connection to remote SSH server using verbose output.

In this example, I’m checking connectivity to vps1 server on port 212:

[email protected]:~ $ ssh -vvv vps1.unixtutorial.org -p 212
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for *
debug2: resolving "vps1.unixtutorial.org" port 212
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to vps1.unixtutorial.org [51.15.230.209] port 212.
debug1: connect to address 51.15.230.209 port 212: Connection refused
ssh: connect to host vps1.unixtutorial.org port 212: Connection refused
the same command to a working SSH port will confirm that connection is established:

[email protected]:~ $ ssh -vvv vps1.unixtutorial.org -p 22
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for *
debug2: resolving "vps1.unixtutorial.org" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to vps1.unixtutorial.org [51.15.230.209] port 22.
debug1: Connection established.

That’s it for today!

See Also




Keep Learning with Me

Follow me on Facebook and Twitter or jump into Telegram chat!:
I'm using Brave browser
Give it a try, it's awesome: Brave Browser
IT Consultancy
I'm a principal consultant with Tech Stack Solutions. I help with cloud architectrure, AWS deployments and automated management of Unix/Linux infrastructure. Get in touch!

Recent Tweets