Assume that you have a pair of UNIX/Linux machines. You want to check if both machines can connect to each other via an arbitrary port, say, TCP 111.

Log into the shell of Machine 1 ( If Telnet is installed on it, you can check the connectivity with by using the command

$ telnet 111

But some UNIX/Linux systems do not have Telnet by default. SSH is more popular thus it may be preferred, especially when you don't want to install exra applications on your machine.

An illustration

Question. Is there any way to test the same with ease, by using the ssh command instead of the telnet command?

(Please answer the question. "You can install Telnet or use Microsoft Windows" doesn't help. TCP 111 is just an example.)

  • 1
    You can use netcat or just bash with /dev/tcp/ instead of telnet. And probably many other tools. This sounds like a totally artificial question.
    – user313992
    Feb 2, 2021 at 0:34
  • ssh is the wrong tool (arguably as is telnet) Feb 2, 2021 at 0:48
  • No nc, telnet, Microsoft Windows, or any non-standard tools please. As far as I know /dev/tcp opens a TCP connection to the associated socket..
    – Culip
    Feb 2, 2021 at 0:54

1 Answer 1


I guess you can be certain that ssh is installed, but not nc. In light of that, the question could make sense.

Use the -p option. For example port open:

$ ssh -p 111
ssh_exchange_identification: read: Connection reset by peer

Port closed:

$ ssh -p 112
ssh: connect to host port 112: Connection refused
  • I am pretty certain that nc is not as common as ssh. For example, CentOS 7 doesn't come with nc by default.
    – Culip
    Feb 2, 2021 at 16:55
  • This tip also helps those on Windows, as telnet was disabled starting with Vista, but ssh (openssh) has been bundled since later versions of Windows 10 and Server 2019. Oct 1, 2023 at 19:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .