Using curl for telnet testing on macOS High Sierra and later
2021-05-24 01:18:45 Author: derflounder.wordpress.com(查看原文) 阅读量:707 收藏

Home > Mac administration, macOS > Using curl for telnet testing on macOS High Sierra and later

Using curl for telnet testing on macOS High Sierra and later

As part of introducing macOS High Sierra, Apple removed the telnet tool from macOS. This was part of Apple’s overall effort to improve security, as telnet does not use encryption and its traffic can be intercepted and read. However, telnet did (and does) serve a useful function as a quick way to check if it is possible to connect to a remote server on a particular port.

While there are alternative tools available for this task (like netcat), it’s also possible to still create a telnet connection on macOS using another tool: curl

For more details, please see below the jump.

You can use curl to create a telnet connection using a command similar to the one shown below:

curl -v telnet://ip.address.here:port.number.here

Note: You can also use a DNS address in place of ip.address.here.

For example, if you want to check if https://www.yahoo.com is responding on port 443, use the curl command shown below:

curl -v telnet://www.yahoo.com:443

You should see output similar to that shown below:

username@computername ~ % curl -v telnet://www.yahoo.com:443
*   Trying 74.6.143.26...
* TCP_NODELAY set
* Connected to www.yahoo.com (74.6.143.26) port 443 (#0)
^C
username@computername ~ %

Note: Once successfully connected, use Control+C to break the telnet connection.

If the port is not open, you should see different output. For example, if you want to check if http://www.yahoo.com is responding on port 444, use the curl command shown below:

curl -v telnet://www.yahoo.com:444

Port 444 is not open, so you should see output similar to that shown below:

username@computername ~ % curl -v telnet://www.yahoo.com:444
*   Trying 74.6.143.26...
* TCP_NODELAY set
* connect to 74.6.143.26 port 444 failed: Connection refused
*   Trying 74.6.143.25...
* TCP_NODELAY set
* connect to 74.6.143.25 port 444 failed: Connection refused
* Failed to connect to www.yahoo.com port 444: Connection refused
* Closing connection 0
curl: (7) Failed to connect to www.yahoo.com port 444: Connection refused
username@computername ~ %

文章来源: https://derflounder.wordpress.com/2021/05/23/using-curl-for-telnet-testing-on-macos-high-sierra-and-later/
如有侵权请联系:admin#unsafe.sh