Tomcat 的 8005 端口说明及一些安全设置

本文介绍了如何启动和查看Tomcat的8005端口,讲解了其在server.xml中的配置,并强调了通过修改shutdown脚本和限制server.xml文件权限来提高服务安全性的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、启动 Tomcat,并查看端口

[root@Tang ~]# systemctl start tomcat.service
[root@Tang ~]# ss -tnl
State       Recv-Q Send-Q                     Local Address:Port                                    Peer Address:Port              
LISTEN      0      128                                    *:22                                                 *:*                  
LISTEN      0      100                            127.0.0.1:25                                                 *:*                  
LISTEN      0      100                                   :::8009                                              :::*                  
LISTEN      0      100                                   :::8080                                              :::*                  
LISTEN      0      128                                   :::22                                                :::*                  
LISTEN      0      1                       ::ffff:127.0.0.1:8005                                              :::*             

2、查看 server.xml 中关于 8005 端口的配置

[root@Tang ~]# cat /etc/tomcat/server.xml | grep 8005
<Server port="8005" shutdown="SHUTDOWN">

3、登陆 8005 端口,输入 SHUTDOWN,停止 Tomcat 服务

[root@Tang ~]# telnet 127.0.0.1 8005
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
SHUTDOWN
Connection closed by foreign host.
[root@Tang ~]# ss -tnl
State       Recv-Q Send-Q                     Local Address:Port                                    Peer Address:Port              
LISTEN      0      128                                    *:22                                                 *:*                  
LISTEN      0      100                            127.0.0.1:25                                                 *:*                  
LISTEN      0      128                                   :::22                                                :::*                  

4、为了安全,建议修改 shutdown 的执行代码

[root@Tang ~]# vim /etc/tomcat/server.xml 
[root@Tang ~]# cat /etc/tomcat/server.xml | grep 8005
<Server port="8005" shutdown="Nao1001Tabf">
[root@Tang ~]# systemctl start tomcat.service
[root@Tang ~]# ss -tnl
State       Recv-Q Send-Q                     Local Address:Port                                    Peer Address:Port              
LISTEN      0      128                                    *:22                                                 *:*                  
LISTEN      0      100                            127.0.0.1:25                                                 *:*                  
LISTEN      0      100                                   :::8009                                              :::*                  
LISTEN      0      100                                   :::8080                                              :::*                  
LISTEN      0      128                                   :::22                                                :::*                  
[root@Tang ~]# ss -tnl
State       Recv-Q Send-Q                     Local Address:Port                                    Peer Address:Port              
LISTEN      0      128                                    *:22                                                 *:*                  
LISTEN      0      100                            127.0.0.1:25                                                 *:*                  
LISTEN      0      100                                   :::8009                                              :::*                  
LISTEN      0      100                                   :::8080                                              :::*                  
LISTEN      0      128                                   :::22                                                :::*                  
LISTEN      0      1                       ::ffff:127.0.0.1:8005                                              :::*                  
[root@Tang ~]# telnet 127.0.0.1 8005
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
Nao1001Tabf
Connection closed by foreign host.
[root@Tang ~]# ss -tnl
State       Recv-Q Send-Q                     Local Address:Port                                    Peer Address:Port              
LISTEN      0      128                                    *:22                                                 *:*                  
LISTEN      0      100                            127.0.0.1:25                                                 *:*                  
LISTEN      0      128                                   :::22                                                :::*                  

5、为了安全,同时使 other 用户对 server.xml 没有可读写操作权限

[root@Tang ~]# ll /etc/tomcat/server.xml 
-rw-r--r--. 1 root tomcat 6616 Nov  4 13:44 /etc/tomcat/server.xml
[root@Tang ~]# chmod o-r /etc/tomcat/server.xml
[root@Tang ~]# ll /etc/tomcat/server.xml 
-rw-r-----. 1 root tomcat 6616 Nov  4 13:44 /etc/tomcat/server.xml
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值