c++ 检查远程主机端口_Linux检查远程主机端口是否打开

方式1:telnet host port

telnet 118.31.63.105 9999

cfa4a78a31cb1242929517faf6e7fe1a.png

方式2:nc -v host port

bb3d99a2c204d0b58e093f9e7961c00b.png

方式3:ssh -v -p port username@ip

-v 调试模式(会打印日志).

-p 指定端口

username可以随意

  • 连接不存在端口

[wyq@localhost ~]$ ssh -v -p 9000 wyq@localhost

OpenSSH_6.4, OpenSSL 1.0.1e-fips 11 Feb 2013

debug1: Reading configuration data /home/wyq/.ssh/config

debug1: Reading configuration data /etc/ssh/ssh_config

debug1: /etc/ssh/ssh_config line 51: Applying options for *

debug1: Connecting to localhost [127.0.0.1] port 9000.

debug1: connect to address 127.0.0.1 port 9000: Connection refused

ssh: connect to host localhost port 9000: Connection refused

"Connection refused"表示端口不可用

  • 连接存在的端口

[wyq@localhost ~]$ ssh -v -p 8080 wyq@localhost

OpenSSH_6.4, OpenSSL 1.0.1e-fips 11 Feb 2013

debug1: Reading configuration data /home/wyq/.ssh/config

debug1: Reading configuration data /etc/ssh/ssh_config

debug1: /etc/ssh/ssh_config line 51: Applying options for *

debug1: Connecting to localhost [127.0.0.1] port 8080.

debug1: Connection established.

debug1: identity file /home/wyq/.ssh/id_rsa type 1

debug1: identity file /home/wyq/.ssh/id_rsa-cert type -1

debug1: identity file /home/wyq/.ssh/id_dsa type -1

debug1: identity file /home/wyq/.ssh/id_dsa-cert type -1

debug1: identity file /home/wyq/.ssh/id_ecdsa type -1

debug1: identity file /home/wyq/.ssh/id_ecdsa-cert type -1

debug1: Enabling compatibility mode for protocol 2.0

debug1: Local version string SSH-2.0-OpenSSH_6.4

debug1: ssh_exchange_identification: <head>

debug1: ssh_exchange_identification: <title>Error response</title>

debug1: ssh_exchange_identification: </head>

debug1: ssh_exchange_identification: <body>

debug1: ssh_exchange_identification: <h1>Error response</h1>

debug1: ssh_exchange_identification: <p>Error code 400.

debug1: ssh_exchange_identification: <p>Message: Bad request syntax ('SSH-2.0-OpenSSH_6.4').

debug1: ssh_exchange_identification: <p>Error code explanation: 400 = Bad request syntax or unsupported method.

debug1: ssh_exchange_identification: </body>

ssh_exchange_identification: Connection closed by remote host

"Connection established" 表示已经连上端口

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值