【问题标题】:Connect to Mac running behind NAT on custom SSH port with Xamarin Mac agent使用 Xamarin Mac 代理连接到在自定义 SSH 端口上运行在 NAT 后面的 Mac
【发布时间】:2018-01-18 11:57:27
【问题描述】:

我有 Mac,可以通过路由器上的 NATed 端口 6535 从外部网络访问;路由器本身也暴露了 22 端口。我希望通过 Xamarin Mac 代理从外部网络连接到我的 Mac。

我可以通过 SSH(腻子)连接到路由器和 Mac,但是当我尝试从 Visual Studio 2017(或 MsBuild 命令提示符)连接到 Mac 时,输入服务器 IP 类似 1.1.1.1:6535(其中1.1.1.1 被我的路由器外部 IP 取代)- 我通过指纹看到,Studio 正在使用端口 22 进行连接(我看到我的路由器指纹,而不是我的 Mac 指纹)。

是否可以从在 Visual Studio 和 MsBuild 中运行的 Xamarin Mac 代理连接到自定义端口?

Can the Xamarin Mac Agent's port be configured? (to something other than port 22) - 提示我需要先连接成功,但我不能。从连接成功的机器导入注册表项无济于事,因为 VS 仍在尝试通过指纹看到的端口 22 连接到远程主机(因此,我仍然无法从 Visual Studio 连接)。如果我尝试直接调用 MsBuild - 它也会失败,因为 MsBuild 只是忽略了端口指令。

我在提升的开发人员命令提示符下使用以下 cmdline 启动 MsBuild:msbuild mySolution.sln /t:Clean;Build /p:Configuration="Release";IpaPackageDir=C:\t\;Platform=iPhone;ServerAddress=1.1.1.1;ServerPort=6535;ServerUser=user;ServerPassword=password

我收到以下回复:

_SayHello:
  Connecting to Mac server 1.1.1.1...
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\iOS\Xamarin.iOS.Windows.After.targets(63,
5): warning : Ignoring server port when the build is not running inside Visual Studio. [myprojectpath\myproject.csproj]
  Starting connection to 1.1.1.1...

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\iOS\Xamarin.iOS.Windows.After.targets(63,
5): warning : Could not authenticate the user 'user' with the provided credentials [myprojectpath\myproject.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\iOS\Xamarin.iOS.Windows.After.targets(63,
5): warning VSX1000: A connection to the Mac Server couldn't be established with Address='1.1.1.1' and User='user', so only the main assembly was compiled for project 'myproject'. Connect to a Mac Server and try again to build
the full application. [myprojectpath\myproject.csproj]

【问题讨论】:

  • 您可以随时在路由器上设置端口转发,将路由器上的外部端口 22 转发到 Mac 上的内部端口 6535 或 22。
  • 不,路由器上的 22 端口已被占用,我无法交换此分配 :(
  • 为什么不呢?它是否已经路由到另一台计算机?还是路由器根本不允许您更改此设置?你有什么路由器?
  • 路由器已经将端口 22 路由到其他计算机,并且这些服务在全球范围内使用,因此我无法为 Mac NATting 暴露端口 22。我暴露了端口 6535 并将其 NAT 到 Mac 上的端口 22 - 并且可以与 ssh (Putty) 完美连接。

标签: xamarin xamarin.ios msbuild visual-studio-2017


【解决方案1】:

请看下面的帖子,我相信这会对你有所帮助。

Configure xamarin Mac agent port to something other than 22

我已经标记了这个,因为我认为它在大多数意义上是重复的。

跟进:在您的路由器配置中,您可以:

  1. 暂时将端口映射 22 分配给您的 Mac 并进行测试以确保它有效,然后您可以将其重新设置。
  2. 创建一个端口映射,将“路由器外部”(您的 6*** 号)指向“mac IP 地址内部端口 22”,如果您的路由器最像,您应该能够将此外部端口分配给 Mac 的端口 22 上的 IP。

如果您对此有任何疑问,请提供上述路由器配置的屏幕截图,以便我们提供帮助。

问候

编辑:添加额外信息

【讨论】:

  • 我添加了更多数据来提问,以澄清为什么它对我来说似乎不是重复的。另外,您所指的帖子也暗示您首先应在端口 22 上成功连接,这在我的情况下是不可能的。
  • 我已经添加了更多答案
  • 它看到这个解决方案停止在新的 VS/Xamarin 版本上工作...... :(
  • 如果新版本的安全性可能发生了巨大变化,您可能必须取消阻止防火墙端口。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-09-10
  • 1970-01-01
  • 2016-12-22
  • 2015-02-10
  • 1970-01-01
  • 2016-07-20
  • 1970-01-01
相关资源
最近更新 更多