首页 文章

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

提问于
浏览
20

我正在继续冒险与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 walkthrough .

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

enter image description here

此时登录工作正常 .

enter image description here

然后,在解决方案中,我将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项目,构建它并运行模拟器 . 有用 .

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

EDIT:

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

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 ---

EDIT 2:

我修改了troubleshooting Xamarin page,特别是它说"Unable to authenticate with SSH keys. Please try to log in with credentials first" .

我跑了:

chmod og-w "$HOME"
grep sshd /var/log/system.log > "$HOME/Desktop/sshd.log"
cd Desktop
cat sshd.log

并且文件的内容是:

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

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

13 回答

  • 0

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

    %localappdata%\Xamarin\MonoTouch
    

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

  • 25

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

    • In my Windows: 我已从"%localappdata%\Xamarin\MonoTouch."删除了内容

    • In Mac terminal: 删除authorized_keys Mac文件(在我的情况下为"rm /Users/macmini2/.ssh/authorized_keys")

    • In Mac terminal: chmod g-w / Users / macmini2 /

    • In Mac terminal: chmod 700 /Users/macmini2/.ssh/

    • In Mac terminal: 创建一个空文件:/Users/macmini2/.ssh/authorized_keys(例如,使用vim)

    • In Mac terminal: chmod 600 /Users/macmini2/.ssh/authorized_keys

    • On Visual Studio: 使用Xamarin Mac Agent登录

    • On Visual Studio: 使用[Debug] - [iPhoneSimulator] - [iPhone 5 iOS 8.1]运行应用程序

    • 最后,模拟器在Mac计算机上运行 .

    This link帮助了我 .

  • 1

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

    Connection Troubleshooting

    特别是这两个:

    Log File Location

    Mac – ~/Library/Logs/Xamarin-[MAJOR.MINOR]
    Windows – %LOCALAPPDATA%\Xamarin\Logs
    

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

    "Unable to authenticate with SSH keys. Please try to log in with credentials first"

    已知原因:

    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".
    

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

    "Couldn't connect to MacBuildHost.local. Please try again."

    报告原因:

    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.
    
  • 4

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

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

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

    你下一步需要做什么:

    • 如果一切正常,请遵循xamarin社区关于mac连接的解决方案,如果一切正常,您将连接,但如果没有..

    • 在MAC上安装XAMARIN STUDIO . 安装完成后启动XAMARIN studio,创建自己的应用程序并使用模拟器运行

    • 关闭应用程序并尝试从Windows计算机再次连接 . 此时,您将进行同步,这就是全部 .

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

  • 1

    对于我帮助下一个解决方案:1)在Windows上打开Visual Studio:工具=>选项=> Xamarin =>其他并单击立即检查

    2)在Mac上打开Xamarin工作室社区(https://www.xamarin.com/download)Xamarin工作室社区=>检查更新...(并下载最后一个)

    更新后一切正常 .

  • 5

    我尝试了一些这里提到的解决方案并没有成功 .

    但是(虽然不是很理想)如果我在管理员模式下运行Visual Studio,我可以成功连接 . 在找到更好的解决方案之前,可以解决一些问题 .

  • 0

    对于它的 Value ,我通过检查上述日志和Xamarin故障排除文档中的日志来解决此问题 . 它原来是iOS版本不匹配 . 一旦我更新了Mac版本就可以了 .

    enter image description here

  • 6

    这不是完美的解决方案,但在我的案例中取得了成功

    您的mac帐户不应包含任何特殊字符 - 这是与Windows连接到mac的限制

    company-mac1 ---错了

    comapanymac1 ---正确

  • 2

    在我的情况下,我在我的Mac上安装了单声道sdk它解决了问题http://www.mono-project.com/download/#download-mac

  • 0

    忽略Visual Studio向导显示的代理 . 有关Mac电脑名称VS的事情并不明白 .

    我做了'添加Mac',使用了IP地址,然后连接了 . 这很烦人 .

  • 14

    您是否打开了远程登录,这是当前登录到计算机的用户/登录?此外,您是否尝试过直接连接到IP地址而不是DNS名称?

    我在客户的网络(不同于我的域),我的VS永远不会通过计算机名连接 . 我 always 必须输入IP地址 . 另外,在输出面板/窗口中观察"Xamarin"的输出,看看它是否提供了更多有用的信息 .

  • 1

    我最近遇到了这个问题(尽管在OSX主机上启用了共享并检查了防火墙),结果发现OSX Machine和Windows Machine都需要完全相同版本的Xamarin.iOS并重启 .

    更新两者,重新启动两者,为我解决了问题 .

  • 1

    我认为为我修复的是打开 git bash 然后运行 ssh onto the mac box . 说 Ytrusting credentials 之后就有用了 .

相关问题