Linux 判断某个IP上的端口是否通的 telnet ssh服务

今天发现在某个linux 服务器上想测试某个服务器上的端口是否是通畅的,于是telnet IP 端口  正常情况下

通的  

[root@1222 ~]# telnet 127.0.0.1 4531
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.

若不通

[root@1222 ~]# telnet 127.0.0.1 4581
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused

但今天这个服务器上并没有安装telnet 服务  怎么办了  下面介绍ssh 的方式去检查服务器端口是否开启

用法: ssh -v -p port username@ip

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

-p 指定端口

username可以随意  即服务器IP或主机名

1)连接不存在端口

[root@1222 ~]# ssh -v -p 53425 root@127.0.0.1
OpenSSH_6.6.1, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 56: Applying options for *
debug1: Connecting to 127.0.0.1 [127.0.0.1] port 9002.
debug1: connect to address 127.0.0.1 port 9002: Connection refused
ssh: connect to host 127.0.0.1 port 9002: Connection refused

2)连接存在端口

[root@1222 ~]# ssh -v -p 53213 root@127.0.0.1
OpenSSH_.p, OpenSSL ..e-fips Feb
debug: Reading configuration data /etc/ssh/ssh_config
debug: Applying options for *
debug: Connecting to ... [...] port .
debug: Connection established.
debug: permanently_set_uid: /
debug: identity file /root/.ssh/identity type -
debug: identity file /root/.ssh/identity-cert type -
debug: identity file /root/.ssh/id_rsa type -
debug: identity file /root/.ssh/id_rsa-cert type -
debug: identity file /root/.ssh/id_dsa type -
debug: identity file /root/.ssh/id_dsa-cert type -

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值