Use SSH to determine if the port is in a Linux environment

Source: Internet
Author: User
Tags openssl connection reset

Use SSH to determine if the port is in a Linux environment


In the Windows/linux environment, you can use Telnet to determine the port status, but sometimes there is no telnet in the Linux environment, so you can use SSH to determine the port status.

First, SSH use method:

Command: SSH-V-p port [email protected]

Description:-v debug mode, which will enter log information

-P Port number

Second, install the httpd on the Server01

First install the httpd under the Linux system and start port 80.

Yum Install httpd

Systemctl Start Httpd.service

Firewall-cmd--permanent--add-service=http

Firewall-cmd--reload

Firewall-cmd--list-all

Third, use SSH to test port status in Server02

[Email protected]/]# ssh-v-P [email protected]

OPENSSH_5.3P1, OpenSSL 1.0.0-fips 2010

Debug1:reading Configuration Data/etc/ssh/ssh_config

Debug1:applying Options for *

Debug1:connecting to 192.168.16.111 [192.168.16.111] Port 8800.

Debug1:connect to address 192.168.16.111 Port 8800:no route to host

Ssh:connect to host 192.168.16.111 Port 8800:no route to host

[Email protected]/]#

Output "No route to host", indicating that the port is not through.

or the output "Connection refused", indicating that the port is not through.

[Email protected]/]# ssh-v-p [email protected]

OPENSSH_5.3P1, OpenSSL 1.0.0-fips 2010

Debug1:reading Configuration Data/etc/ssh/ssh_config

Debug1:applying Options for *

Debug1:connecting to 192.168.16.111 [192.168.16.111] Port 80.

DEBUG1: Connection established.

debug1:permanently_set_uid:0/0

Debug1:identity file/root/.ssh/identity type-1

Debug1:identity File/root/.ssh/identity-cert type-1

Debug1:identity File/root/.ssh/id_rsa type-1

Debug1:identity File/root/.ssh/id_rsa-cert type-1

Debug1:identity FILE/ROOT/.SSH/ID_DSA type-1

Debug1:identity File/root/.ssh/id_dsa-cert type-1

Ssh_exchange_identification:connection Closed by remote host

If the output is "Connection established", the connection is successful.

IV. testing port connectivity using the Wget tool

[Email protected]/]# wget 192.168.16.111:99

--2017-07-21 21:01:16--http://192.168.16.111:99/

Connecting 192.168.16.111:99 ... failed: No route to host

[Email protected]/]# wget 192.168.16.111:80

--2017-07-21 21:01:28--http://192.168.16.111/

Connecting 192.168.16.111:80 ... is connected .

An HTTP request has been made and is waiting for a response ... 403 Forbidden

2017-07-21 21:01:28 error 403:forbidden.

[Email protected]/]# wget 192.168.16.111:22

--2017-07-21 21:01:38--http://192.168.16.111:22/

Connecting 192.168.16.111:22 ... is connected .

An HTTP request has been made and is waiting for a response ... 200 no HTTP headers, try http/0.9

Length: Not Specified

Saving to: "INDEX.HTML.1"

[<=>]42--.-k/s in 0s

2017-07-21 21:01:38 (282 kb/s)-A read error occurred at 42 bytes (Connection reset by peer). Retry.

--2017-07-21 21:01:39--(Number of attempts: 2) http://192.168.16.111:22/

Connecting 192.168.16.111:22 ... is connected.

An HTTP request has been made and is waiting for a response ... 200 no HTTP headers, try http/0.9

The file has been downloaded, and no action will be taken.

[Email protected]/]#


This article is from the "Wind Valley" blog, please be sure to keep this source http://chenchunjia.blog.51cto.com/1878790/1949710

Use SSH to determine if the port is in a Linux environment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.