首页 > 解决方案 > Mac 无法访问端口 22

问题描述

总之,我无法连接到端口 22。要允许连接端口 22,我需要使用ufw它来设置它,但我无法在我的机器上这样做。

我试图通过运行命令来连接服务器

ssh username@xx.xxx.xxx.xx

但我收到以下错误

ssh: connect to host username@xx.xxx.xxx.xx port 22: Operation timed out

我用谷歌搜索并发现问题与端口 22 连接有关,因此我按照建议尝试了以下命令。

sudo ufw allow 22/tcp

但我似乎需要先安装ufw。我按照建议运行以下命令。

sudo apt-get install ufw  

但似乎我需要安装apt-get. 我试图安装它,但这篇文章说 Mac 只使用 Brew。https://stackoverflow.com/questions/5231160/sudo-apt-get-command-not-found. 我尝试使用 brew ,但这就是我得到的。

brew install ufw

    xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

==> Searching for similarly named formulae...
Error: No similarly named formulae found.
Error: No available formula or cask with the name "ufw".
==> Searching for a previously deleted formula (in the last month)...
Warning: homebrew/core is shallow clone. To get its complete history, run:
  git -C "$(brew --repo homebrew/core)" fetch --unshallow

Error: No previously deleted formula found.
==> Searching taps on GitHub...
Error: No formulae found in taps.

我该如何解决这个问题?谢谢你。

标签: linuxserverporthpc

解决方案


最终我发现问题与我的 VPN 有关。我无法使用我当前的 VPN 连接到端口。但是,我可以使用另一台计算机连接到该端口,因为它使用了正确的 VPN。


推荐阅读