linux – 在命令行中使用wireshark / tshark来忽略ssh连接

我正在尝试通过查看数据包来调试一些,我想避免将所有SSH流量都发送到服务器.有没有办法忽略?

我尝试做类似tshark -f“port!22”之类的东西,但它在命令后停止了监听.

[root@vpn ~]# tshark -f "port !22"
tshark -f "port ls"
Running as user "root" and group "root". This Could be dangerous.
Capturing on venet0
tshark: arptype 65535 not supported by libpcap - falling back to cooked socket.

tshark: Invalid capture filter: "port ls"!

That string isn't a valid capture filter (unkNown port 'ls').
See the User's Guide for a description of the capture filter Syntax.
0 packets captured
[root@vpn ~]#

解决方法

tshark和tcpdump都使用pcap库,因此捕获过滤器使用 pcap-filter syntax.你想要的过滤器,如@tristan所说,“不是端口22”.您可以将此输入作为-f选项的带引号的字符串参数,或作为命令的不带引号的参数.以下命令是等效的:
# tshark -f "not port 22"
# tshark -- not port 22

tshark抱怨你上面命令的原因是你的shell(可能是Bash)在命令历史中将“!22”扩展为命令编号22,在本例中是“ls”. Bash documentation有更多关于历史扩张的信息.

相关文章

1、安装Apache。 1)执行如下命令,安装Apache服务及其扩展包...
一、先说一下用ansible批量采集机器信息的实现办法: 1、先把...
安装配置 1. 安装vsftpd 检查是否安装了vsftpd # rpm -qa | ...
如何抑制stable_secret读取关键的“net.ipv6.conf.all.stabl...
1 删除0字节文件 find -type f -size 0 -exec rm -rf {} ...
## 步骤 1:安装必要的软件包 首先,需要确保系统已安装 `dh...