netstat -tnlp|grep 22
时间: 2023-10-25 10:39:32 浏览: 50
This command will show all active TCP connections with their local and remote IP addresses, ports, and the process ID listening on port 22 (which is typically used for SSH connections). The output can be helpful for troubleshooting network connectivity issues or identifying unauthorized access attempts to a system.
相关问题
我的k8s环境中 nodeport端口通过netstat命令或者ss -tnlp都查不到 但是可以正常使用
这种情况可能是因为在 Kubernetes 集群中使用的是 NodePort 类型的服务,它是通过 iptables 转发实现的。因此,在节点上使用 netstat 或 ss 命令是无法看到 NodePort 的监听端口的。
如果您想查看 Kubernetes NodePort 服务的端口映射,可以运行以下命令:
```
kubectl get svc <service-name> -o jsonpath='{.spec.ports[0].nodePort}'
```
其中,`<service-name>` 是您要查看的服务名称。该命令将返回 NodePort 端口号。
如果您仍然想通过 netstat 或 ss 命令查看转发规则,可以执行以下命令:
```
iptables-save | grep KUBE-SERVICES | grep <service-name>
```
其中,`<service-name>` 是您要查看的服务名称。该命令将返回与该服务相关的 iptables 规则,其中包括 NodePort 的监听端口。
ssh: connect to host 10.250.0.228 port 22: Resource temporarily unavailable
这个错误提示通常是因为目标机器的 SSH 服务端口(默认是22)被占用或者 SSH 服务未启动导致无法连接。你可以尝试以下几种方法解决该问题:
1. 确认目标机器的 SSH 服务已经启动,可以通过在目标机器上运行命令 `sudo service ssh status` 来查看 SSH 服务的状态。
2. 确认目标机器的防火墙没有阻止 SSH 连接,可以通过在目标机器上运行命令 `sudo ufw status` 来查看防火墙的状态。
3. 确认目标机器的 SSH 服务端口没有被占用,可以通过在目标机器上运行命令 `sudo netstat -tnlp | grep 22` 来查看 SSH 服务端口的占用情况。
4. 如果以上方法都不能解决问题,可以尝试重启目标机器的 SSH 服务,可以通过在目标机器上运行命令 `sudo service ssh restart` 来重启 SSH 服务。
相关推荐
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)