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 -