日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

怎么判断linux22端口是否通,在Linux环境下使用SSH判断端口是否通(示例代码)

發布時間:2024/7/23 linux 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 怎么判断linux22端口是否通,在Linux环境下使用SSH判断端口是否通(示例代码) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

在Linux環境下使用SSH判斷端口是否通

在windows/linux環境下,可以使用telnet判斷端口狀態,但有時候在Linux環境下沒有telnet,所以可以使用ssh判斷端口狀態。

一、ssh使用方法:

命令:ssh -v -p port [email?protected]

說明:-v ?調試模式,會輸入日志信息

-p? 端口號

二、在server01上安裝httpd

首先在Linux系統下安裝httpd,啟動80端口。

yum install httpd

systemctl start httpd.service

firewall-cmd --permanent --add-service=http

firewall-cmd --reload

firewall-cmd --list-all

三、在server02使用ssh測試端口狀態

OpenSSH_5.3p1, OpenSSL 1.0.0-fips 29 Mar 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

輸出“No route to host”,說明端口不通。

或者輸出“Connection refused”,說明端口不通。

OpenSSH_5.3p1, OpenSSL 1.0.0-fips 29 Mar 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

如果輸出“Connection established”,則表示連接成功。

四、使用wget工具測試端口連通性

[[email?protected] /]# wget 192.168.16.111:99

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

正在連接 192.168.16.111:99... 失敗:沒有到主機的路由

[[email?protected] /]# wget 192.168.16.111:80

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

正在連接 192.168.16.111:80... 已連接。

已發出 HTTP 請求,正在等待回應...403 Forbidden

2017-07-21 21:01:28 錯誤 403:Forbidden。

[[email?protected] /]# wget 192.168.16.111:22

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

正在連接 192.168.16.111:22... 已連接。

已發出 HTTP 請求,正在等待回應...200 沒有 HTTP 頭,嘗試 HTTP/0.9

長度:未指定

正在保存至: “index.html.1”

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

2017-07-21 21:01:38 (282 KB/s) - 在 42 字節處發生讀取錯誤 (Connection reset by peer)。重試中。

--2017-07-21 21:01:39--? (嘗試次數: 2)? http://192.168.16.111:22/

正在連接 192.168.16.111:22... 已連接。

已發出 HTTP 請求,正在等待回應...200 沒有 HTTP 頭,嘗試 HTTP/0.9

文件已下載完成;不會進行任何操作。

總結

以上是生活随笔為你收集整理的怎么判断linux22端口是否通,在Linux环境下使用SSH判断端口是否通(示例代码)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。