I can't connect to Mac with Xamarin Mac Agent

2019-01-17 15:46发布

I'm continuing my adventure with Xamarin.

I'm developing an Xamarin Forms application with a Portable Class Libraries (PCL).

I have compiled and debugged my application by Android, but now, I'm interested to run the application in iOS to test in this platform.

I have a problem with the connection between my PC and the Mac.

I have a PC (Windows 8.1) with Visual Studio Community 2015 with Xamarin tools installed.

In my Mac Mini, I have installed OS X (v10.11.3), XCode (v7.2) and Xamarin Studio. I have logged in with my Xamarin account.

In the two machines I have the same Xamarin version.

I have followed the Xamarin walkthrough.

On Visual Studio I open the Xamarin Mac Agent. It finds my Mac Mini. Then it asks me the Mac credentials (user and password).

enter image description here

The login works at this point.

enter image description here

Then, in the solution, I set the iOS project as the startup project. I clean the solution, I build again and start the compile/debug process (F5).

In this point, the output retrieves a message:

1> Connecting to Mac server Macs-Mac-mini.local...

1>C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Windows.After.targets(54,5): warning : Could not authenticate the user using the existing ssh keys

1>C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Windows.After.targets(54,5): error : Unable to connect to Address='Macs-Mac-mini.local' with User='macmini

I have used Putty (SSH Client) to check with my user/password if I'm able to connect to Mac, and I have had success.

Into /Users/macmini2/.ssh/authorized_keys file (Mac machine) each time that I use the Xamarin Mac Agent, Visual Studio adds a new key entry (it adds the same repeated).

I see that perhaps the problem is related with ssh keys. Why I have this problem? What am I doing wrong?

A thing that I have tested was openning the Xamarin project directly in Mac with Xamarin Studio, build it and run the simulator. It works.

I have seen other similar question, but I think that it doesn't have the same problem.

EDIT:

More specific information about the error when I try to compile/debug:

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:

I have revised the troubleshooting Xamarin page, specifically that it says "Unable to authenticate with SSH keys. Please try to log in with credentials first".

I have run:

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

And the content of the file is:

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

But now I don't know what I have to do to solve it.

13条回答
Ridiculous、
2楼-- · 2019-01-17 16:08

I tried a few of the solutions mentioned here and had no success.

However (though not ideal) if I run Visual Studio in Administrator Mode I can successfully connect. Could be a work around for some until a better solution is found.

查看更多
对你真心纯属浪费
3楼-- · 2019-01-17 16:09

For what it's worth I just solved this issue by checking the logs as noted above and in the Xamarin Troubleshooting docs. It turned out to be mismatched iOS versions. Once I updated the Mac version it worked.

enter image description here

查看更多
干净又极端
4楼-- · 2019-01-17 16:11

In my case, i installed mono sdk on my mac it solve the problem http://www.mono-project.com/download/#download-mac

查看更多
女痞
5楼-- · 2019-01-17 16:20

I have just solved this problem! It was nonsense.

To connect Visual Studio Xamarin project and simulate that on Mac when you get:

Couldn't connect to computername.local please try again later.

What you need to do next:

  1. Follow the solution from xamarin community about mac connection after this point if everything OK, you will connect, but if no..
  2. Install XAMARIN STUDIO on MAC. After installation start XAMARIN studio, create your own app and run with simulator
  3. Close app and try to connect again from Windows computer. At this point you will make synchronization and that's all.

Problem solved! I hope this will be useful for somebody.

查看更多
smile是对你的礼貌
6楼-- · 2019-01-17 16:20

Did you turn on remote login and that is the user/login that is currently logged into the machine? Also, have you tried connecting directly to the IP address instead of the DNS name?

I am on a client's network (different domain than mine) and my VS would never connect via the computer name. I always had to type in the IP address. Also, watch the out put for "Xamarin" in the Output panel/window and see if it gives any more helpful information.

查看更多
看我几分像从前
7楼-- · 2019-01-17 16:22

Ignored the agent that Visual Studio wizard showed. Something about the Mac computer name VS didn't understand.

I did 'Add Mac', used the IP address, then it connected. That was annoying.

查看更多
登录 后发表回答