温馨提示×

debian怎样用openssl测端口

小樊
51
2026-10-08 11:26:35
栏目: 云计算

在 Debian 上,可以用 OpenSSL 的 s_client 来测试(尤其是 HTTPS / TLS 端口)。下面按常见场景说明。


一、测试 HTTPS(TLS)端口

例如测试 example.com 的 443 端口:

openssl s_client -connect example.com:443

如果你想看证书信息:

openssl s_client -connect example.com:443 | openssl x509 -noout -text

或者只看关键信息:

openssl s_client -connect example.com:443 2>/dev/null | openssl x509 -noout -dates -subject

二、指定 SNI(虚拟主机必用)

现代网站通常需要 SNI:

openssl s_client -connect example.com:443 -servername example.com

三、测试非标准 TLS 端口

例如 8443:

openssl s_client -connect example.com:8443 -servername example.com

四、测试 SMTP / IMAP / POP3 的 TLS

SMTP(587 / 465)

openssl s_client -connect mail.example.com:587 -starttls smtp

IMAP(993)

openssl s_client -connect mail.example.com:993

POP3(995)

openssl s_client -connect mail.example.com:995

五、测试完成后手动发请求(可选)

连接成功后,可以手动输入 HTTP 请求:

GET / HTTP/1.1
Host: example.com
Connection: close

按两次回车即可。


六、仅测试端口是否通(非 TLS)

如果不是 TLS,OpenSSL 不适合,推荐用:

nc -vz example.com 80

或

telnet example.com 80

如果你愿意,可以告诉我:

  • 端口号
  • 协议(HTTPS / SMTP / 自定义)
  • 是否需验证证书

我可以给你精确命令。

0 踩