微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

PowerShell SSH 仅适用于 LAN,但不适用于 Internet

如何解决PowerShell SSH 仅适用于 LAN,但不适用于 Internet

我设置了防火墙例外,一切正常

通过家庭互联网 DHCP 工作

甚至尝试关闭域和家庭的防火墙都无济于事。

这是我的代码(只是指南):

# Install the OpenSSH Client
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0

# Install the OpenSSH Server
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0

# Start the sshd service
Start-Service sshd

# OPTIONAL but recommended:
Set-Service -Name sshd -StartupType 'Automatic'

# Confirm the firewall rule is configured. It should be created automatically by setup.
Get-NetFirewallRule -Name *ssh*

# There should be a firewall rule named "OpenSSH-Server-In-TCP",which should be enabled
# If the firewall does not exist,create one
New-NetFirewallRule -Name sshd -displayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22

这里是我用代码做的事情的概要。 SSH client to client hosting in PowerShell

解决方法

您需要打开端口 22/TCP 才能在 LAN 外使用 SSH。

这通常可以在您的路由器配置中实现,也可以通过联系您的提供商来实现。成功执行此操作后,您可以使用 WAN IP 访问网络外的 SSH。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。