我无法使用Visual Studio 2015中的Xamarin Mac Agent连接到Mac

sti*_*vex 20 debugging macos xamarin.ios xamarin.forms visual-studio-2015

我正在继续冒险与Xamarin.

我正在开发一个带有可移植类库(PCL)的Xamarin Forms应用程序.

我已经通过Android编译和调试了我的应用程序,但是现在,我有兴趣在iOS中运行应用程序来测试这个平台.

我的PC和Mac之间的连接有问题.

我有一台装有Xamarin工具的Visual Studio Community 2015的PC(Windows 8.1).

在我的Mac Mini中,我安装了OS X(v10.11.3),XCode(v7.2)和Xamarin Studio.我已经使用我的Xamarin帐户登录了.

在这两台机器中,我有相同的Xamarin版本.

我跟随了Xamarin演练.

在Visual Studio上,我打开Xamarin Mac Agent.它找到我的Mac Mini.然后它会问我Mac凭证(用户名和密码).

在此输入图像描述

此时登录工作正常.

在此输入图像描述

然后,在解决方案中,我将iOS项目设置为启动项目.我清理解决方案,我再次构建并启动编译/调试过程(F5).

在这一点上,输出检索一条消息:

1>连接到Mac服务器Macs-Mac-mini.local ...

1> C:\ Program Files(x86)\ MSBuild\Xamarin\iOS\Xamarin.iOS.Windows.After.targets(54,5):警告:无法使用现有的ssh密钥对用户进行身份验证

1> C:\ Program Files(x86)\ MSBuild\Xamarin\iOS\Xamarin.iOS.Windows.After.targets(54,5):错误:无法连接到地址='Macs-Mac-mini.local'用户='macmini

我已经使用Putty(SSH客户端)检查我的用户/密码,如果我能够连接到Mac,我已经取得了成功.

进入/Users/macmini2/.ssh/authorized_keys文件(Mac机器)每次我使用Xamarin Mac Agent时,Visual Studio都会添加一个新的密钥条目(它重复添加相同的内容).

我看到问题可能与ssh键有关.为什么我有这个问题?我究竟做错了什么?

我测试的一件事就是直接在Mac上用Xamarin Studio打开Xamarin项目,构建它并运行模拟器.有用.

我见过其他类似的问题,但我认为它没有同样的问题.

编辑:

我尝试编译/调试时有关错误的更多具体信息:

Could not authenticate the user using the existing ssh keys
Xamarin.Messaging.VisualStudio.MessagingAuthenticationException: Could not authenticate the user using the existing ssh keys ---> Renci.SshNet.Common.SshAuthenticationException: Permission denied (publickey).
   en Renci.SshNet.ClientAuthentication.Authenticate(IConnectionInfoInternal connectionInfo, ISession session)
   en Renci.SshNet.ConnectionInfo.Authenticate(ISession session)
   en Renci.SshNet.Session.Connect()
   en Renci.SshNet.BaseClient.Connect()
   en Xamarin.Messaging.VisualStudio.MessagingService.<ConnectAsync>d__70.MoveNext()
   --- Fin del seguimiento de la pila de la excepción interna ---
Run Code Online (Sandbox Code Playgroud)

编辑2:

我修改了Xamarin故障排除页面,特别是它说"无法使用SSH密钥进行身份验证.请先尝试使用凭据登录".

我跑了:

chmod og-w "$HOME"
grep sshd /var/log/system.log > "$HOME/Desktop/sshd.log"
cd Desktop
cat sshd.log
Run Code Online (Sandbox Code Playgroud)

并且文件的内容是:

Apr 18 09:23:28 Macs-Mac-mini sshd[769]: Authentication refused: bad ownership or modes for directory /Users/macmini2/.ssh
Apr 18 09:25:27 Macs-Mac-mini com.apple.xpc.launchd[1] (com.openssh.sshd.EE9A94ED-????-....-????-77254934B300[769]): Service exited with abnormal code: 1
Apr 18 09:59:39 Macs-Mac-mini sshd[1036]: Accepted keyboard-interactive/pam for macmini2 from 192.168.54.14 port 60413 ssh2
Apr 18 09:59:39 Macs-Mac-mini sshd: macmini2 [priv][1036]: USER_PROCESS: 1040 ttys000
Run Code Online (Sandbox Code Playgroud)

但现在我不知道我要做些什么来解决它.

小智 26

你必须尝试从中删除所有内容

%localappdata%\Xamarin\MonoTouch
Run Code Online (Sandbox Code Playgroud)

它帮助了我,今天我遇到了同样的问题(或类似问题).


sti*_*vex 14

我找到了关于我的问题的解决方案.我已完成以下步骤:

  1. 在我的Windows中:我已从"%localappdata%\ Xamarin\MonoTouch"中删除了内容.
  2. 在Mac终端中:删除authorized_keys Mac文件(在我的情况下为"rm /Users/macmini2/.ssh/authorized_keys")
  3. 在Mac终端: chmod gw/Users/macmini2 /
  4. 在Mac终端: chmod 700 /Users/macmini2/.ssh/
  5. 在Mac终端中:创建一个空文件:/Users/macmini2/.ssh/authorized_keys(例如,使用vim)
  6. 在Mac终端: chmod 600 /Users/macmini2/.ssh/authorized_keys
  7. 在Visual Studio上:使用Xamarin Mac Agent登录
  8. 在Visual Studio上:使用[Debug] - [iPhoneSimulator] - [iPhone 5 iOS 8.1]运行应用程序
  9. 最后,模拟器在Mac计算机上运行.

这个链接对我有帮助.

  • 关于第5点 - 由于您在终端,您可以使用"touch /Users/macmini2/.ssh/authorized_keys"创建文件 (4认同)
  • 它通过使用权限_chmod -R 755 /Users/test/.ssh_为我工作一旦连接,您可以重置为700目录..../ssh (2认同)

Mar*_*kai 7

Xamarin有一个疑难解答页面,主要关注SSH问题:

连接故障排除

具体这两个:

日志文件位置

Mac – ~/Library/Logs/Xamarin-[MAJOR.MINOR]
Windows – %LOCALAPPDATA%\Xamarin\Logs
Run Code Online (Sandbox Code Playgroud)

可以通过浏览到Visual Studio中的"帮助">"Xamarin">"Zip日志"来找到日志文件.

"无法使用SSH密钥进行身份验证.请先尝试使用凭据登录"

已知原因:

SSH security restriction – This message most often means that one of the files or directories in the fully qualified path of $HOME/.ssh/authorized_keys on the Mac has write permissions enabled for other or group members. Common fix: Run chmod og-w "$HOME" in a Terminal command prompt on the Mac. For details about which particular file or directory is causing the problem, run grep sshd /var/log/system.log > "$HOME/Desktop/sshd.log" in Terminal, and then open the sshd.log file from your Desktop and look for "Authentication refused: bad ownership or modes".
Run Code Online (Sandbox Code Playgroud)

此外,还有这一部分,它与您看到的错误不直接匹配,但在SSH配置和诊断方面有一些细节:

"无法连接到MacBuildHost.local.请再试一次."

报告原因:

Bug – A few users have seen this error message when attempting to log in to the build host using an Active Directory domain user account.

Bug – Some users have seen this error when attempting to connect to the build host by double-clicking the name of the Mac in the connection dialog. Possible workaround: Manually add the Mac using the IP address.

Bug #35971 – Some users have run across this error when using a wireless network connection between the Mac build host and Windows. Possible workaround: Move both computers to a wired network connection.

Bug #36642 – On Xamarin 4.0, this message will appear anytime the $HOME/.bashrc file on the Mac contains an error. (Starting with Xamarin 4.1, errors in the .bashrc file will no longer affect the connection process.) Workaround: Move the .bashrc file to a backup location (or delete it if you know you don't need it).

Limitation – This error can appear if the Mac build host is connected to a router that has no access to the internet (or if the Mac is using a DNS server that times out when asked for the reverse-DNS lookup of the Windows computer). Visual Studio will take roughly 30 seconds to retrieve the SSH fingerprint and eventually fail to connect.

Possible workaround: Add "UseDNS no" to the sshd_config file. Be sure to read about this SSH setting before changing it. See for example http://unix.stackexchange.com/questions/56941/what-is-the-point-of-sshd-usedns-option.

The following steps describe one way to change the setting. You will need to be logged in to an administrator account on the Mac to complete the steps.

    Confirm the location of the sshd_config file by running ls /etc/ssh/sshd_config and ls /etc/sshd_config in a Terminal command prompt. For all of the remaining steps, be sure to use the location that does not return "No such file or directory".

    Run cp /etc/ssh/sshd_config "$HOME/Desktop/" in Terminal to copy the file to your desktop.

    Open the file from your Desktop in a text editor. For example you can run open -a TextEdit "$HOME/Desktop/sshd_config" in Terminal.

    Add the following line at the bottom of the file:

    UseDNS no

    Remove any lines that say UseDNS yes to make sure the new setting takes effect.

    Save the file.

    Run sudo cp "$HOME/Desktop/sshd_config" /etc/ssh/sshd_config in Terminal to copy the edited file back into place. Enter your password if prompted.

    Disable and re-enable Remote Login under System Preferences > Sharing > Remote Login to restart the SSH server.
Run Code Online (Sandbox Code Playgroud)


Jev*_*nov 5

我刚刚解决了这个问题!这是无稽之谈.

要连接Visual Studio Xamarin项目并在Mac上模拟它:

无法连接到computername.local,请稍后再试.

你下一步需要做什么:

  1. 如果一切正常,请遵循xamarin社区关于mac连接的解决方案,如果一切正常,您将连接,但如果没有..
  2. 在MAC上安装XAMARIN STUDIO.安装完成后启动XAMARIN studio,创建自己的应用程序并使用模拟器运行
  3. 关闭应用程序并尝试从Windows计算机再次连接.此时,您将进行同步,这就是全部.

问题解决了!我希望这对某些人有用.