title: I can't connect to Mac with Xamarin Mac Agent from Visual Studio 2015
body: <p>I'm continuing my adventure with Xamarin.</p>
  <p>I'm developing an Xamarin Forms application with a Portable Class Libraries (PCL).</p>
  <p>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.</p>
  <p>I have a problem with the connection between my PC and the Mac.</p>
  <p>I have a PC (Windows 8.1) with Visual Studio Community 2015 with Xamarin tools installed.</p>
  <p>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.</p>
  <p>In the two machines I have the same Xamarin version.</p>
  <p>I have followed the <a href="https://developer.xamarin.com/guides/ios/getting_started/installation/windows/connecting-to-mac/" rel="noreferrer">Xamarin walkthrough</a>.</p>
  <p>On Visual Studio I open the Xamarin Mac Agent. It finds my Mac Mini. Then it asks me the Mac credentials (user and password).</p>
  <p><a href="https://i.stack.imgur.com/XLq6y.png" rel="noreferrer"><img src="https://i.stack.imgur.com/XLq6y.png" alt="enter image description here" /></a></p>
  <p>The login works at this point.</p>
  <p><a href="https://i.stack.imgur.com/RtwwZ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/RtwwZ.png" alt="enter image description here" /></a></p>
  <p>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).</p>
  <p>In this point, the output retrieves a message:</p>
  <blockquote>
  <p>1&gt;  Connecting to Mac server Macs-Mac-mini.local...</p>
  <p>1&gt;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</p>
  <p>1&gt;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</p>
  </blockquote>
  <p>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.</p>
  <p>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).</p>
  <p>I see that perhaps the problem is related with ssh keys.
  Why I have this problem? What am I doing wrong?</p>
  <p>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.</p>
  <p>I have seen other similar <a href="https://stackoverflow.com/questions/36514369/why-does-visual-studio-fail-to-connect-to-mac-agent-for-default-detected-mac-age">question</a>, but I think that it doesn't have the same problem.</p>
  <p><strong>EDIT:</strong></p>
  <p>More specific information about the error when I try to compile/debug:</p>
  <pre><code>Could not authenticate the user using the existing ssh keys
  Xamarin.Messaging.VisualStudio.MessagingAuthenticationException: Could not authenticate the user using the existing ssh keys ---&gt; 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.&lt;ConnectAsync&gt;d__70.MoveNext()
     --- Fin del seguimiento de la pila de la excepción interna ---
  </code></pre>
  <p><strong>EDIT 2:</strong></p>
  <p>I have revised the <a href="https://developer.xamarin.com/guides/ios/getting_started/installation/windows/connecting-to-mac/troubleshooting/#Unable_to_authenticate_with_SSH_keys._Please_try_to_log_in_with_credentials_first" rel="noreferrer">troubleshooting Xamarin page</a>, specifically that it says &quot;Unable to authenticate with SSH keys. Please try to log in with credentials first&quot;.</p>
  <p>I have run:</p>
  <pre><code>chmod og-w &quot;$HOME&quot;
  grep sshd /var/log/system.log &gt; &quot;$HOME/Desktop/sshd.log&quot;
  cd Desktop
  cat sshd.log
  </code></pre>
  <p>And the content of the file is:</p>
  <pre><code>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
  </code></pre>
  <p>But now I don't know what I have to do to solve it.</p>