You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无法通过SSH将Windows端Visual Studio与Mac配对以构建Xamarin/iOS项目

Windows端Visual Studio 2022无法与Mac配对构建.NET MAUI/Xamarin.iOS项目

问题场景

我正尝试将Windows端Visual Studio 2022与Mac配对,以构建.NET MAUI或Xamarin.iOS项目。已拥有Mac的完整终端访问权限,且Mac已启用远程登录(SSH),可通过Windows终端执行ssh username@192.168.###.###成功连接,且已配置SSH密钥认证,无需输入密码。

已执行操作

  • 在Windows端通过ssh-keygen -t rsa -b 4096生成SSH密钥;
  • 将公钥(id_rsa.pub)复制到Mac的~/.ssh/authorized_keys中;
  • 设置权限:
    • chmod 700 ~/.ssh
    • chmod 600 ~/.ssh/authorized_keys
  • 验证密钥放置位置和格式无误;
  • 执行ssh -v Test@192.168.###.###确认已实现密钥认证,无需输入密码。

当前问题

Visual Studio仍无法与Mac配对:

  • 有时提示Error: An error occurred while generating the SSH keys. Please check that the environment is properly configured.
  • 有时点击「添加Mac」后无任何提示,但配对失败。

解决方法

1. 指定Visual Studio使用的SSH密钥路径

打开Visual Studio的「工具>选项>Xamarin>iOS设置」,查看「SSH密钥」对应的路径,确保该路径指向你手动生成的id_rsa文件(通常为C:\Users\[你的Windows用户名]\.ssh\id_rsa)。若路径不符,手动修改为正确路径后重启VS。

2. 重启SSH服务与Visual Studio

  • 关闭Windows端的Visual Studio,重新打开;
  • 在Mac终端执行以下命令重启SSH服务:
    sudo launchctl stop com.openssh.sshd
    sudo launchctl start com.openssh.sshd
    

3. 检查Mac远程登录权限

打开Mac的「系统设置>通用>共享」,确认「远程登录」已勾选,且允许连接的用户列表包含你用来配对的账号(可临时选择「所有用户」测试是否为权限问题)。

4. 手动指定SSH连接参数

在VS的「添加Mac」窗口,输入完整的SSH连接命令,强制指定密钥文件:

ssh Test@192.168.###.### -i C:\Users\[你的Windows用户名]\.ssh\id_rsa

5. 确认Windows端OpenSSH环境

  • 在Windows终端执行where ssh,确认输出包含C:\Windows\System32\OpenSSH\ssh.exe;
  • 若未找到,打开「设置>应用>可选功能>添加功能」,搜索并安装「OpenSSH客户端」。

6. 清除VS配对缓存

关闭Visual Studio,删除以下目录的缓存文件:

  • %LOCALAPPDATA%\Xamarin\MonoTouch
  • %APPDATA%\Microsoft\VisualStudio\[你的VS版本号]\Xamarin
    重新打开VS后再次尝试配对。

内容的提问来源于stack exchange,提问作者Мөнхбаяр

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.12 23:15:59