xamarin 与mac配对错误无法执行“grep“ssh-rsa...”,

0qx6xfy6  于 2022-12-07  发布在  Mac
关注(0)|答案(3)|浏览(131)

I am trying to pair my Macbook with Visual Studio 2022 but after entering the credentials I received the following error in the gui dialog: "An error occurred while trying to establish an SSH connection with SSH keys to '192.168.178.27:22'"
When checking the logs there is the following error:

Xamarin.Messaging.Ssh.SshCommandRunner Warning: 0 : Failed to execute 'grep "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDRpqma2f+6ghu6P2/Jxx2Aj6+4kY/1tFpkvM1CdlscbvESZFsYakl90P9YvXQhHTXhK6QUHgj4E9s+Ze4PxmXSfYd7b3imWpbSOIqWrlC4rfMn31F3EyJ60Cpc9DO15MtiVS9ctTWBKXzRU8NbUlek8LppEID5Xv0nEroryNHEzINXSvyhmTyUHAOklTjm3NVpqLrbGbFw9d6+F8pVskWtYyfFVl9PuW0EhbVox9inWGQIzbCMdVzjGb5M3ua/taNtTz8W6hsUQm8SB7UANR36klHUIWYmSQ5ZgyIkCZ7x6pNyRL2sr6UtFAfsp+vnGsIzakKHvZDXz7uBnRl6/Z7f steve@Stefans-MacBook-Pro.local" "/Users/steve/.ssh/authorized_keys"': ExitStatus = 1: 10.25.2022 22:41:25Z
  DateTime=2022-10-25T22:41:25.3448659Z: 10.25.2022 22:41:25Z

Complete log:

Xamarin.Messaging.Integration.State.ServerStateContext Error: 0 : !An error occurred while trying to establish an SSH connection with SSH keys to '192.168.178.27:22': 10.25.2022 22:36:36Z
  DateTime=2022-10-25T22:36:36.5456548Z: 10.25.2022 22:36:36Z
Xamarin.Messaging.Integration.State.ServerStateContext Information: 0 : Server State transition from DisconnectedState to ConfiguringState on macbook.lan (192.168.178.27): 10.25.2022 22:41:20Z
  DateTime=2022-10-25T22:41:20.2772963Z: 10.25.2022 22:41:20Z
Xamarin.Messaging.Integration.State.ServerStateContext Information: 0 : Checking host configuration for connecting to 'macbook.lan'...: 10.25.2022 22:41:20Z
  DateTime=2022-10-25T22:41:20.3057061Z: 10.25.2022 22:41:20Z
Xamarin.Messaging.Integration.State.ServerStateContext Information: 0 : !Checking host configuration for connecting to 'macbook.lan'...: 10.25.2022 22:41:20Z
  DateTime=2022-10-25T22:41:20.3057061Z: 10.25.2022 22:41:20Z
Xamarin.Messaging.Integration.State.ServerStateContext Information: 0 : Checking SSH configuration...: 10.25.2022 22:41:20Z
  DateTime=2022-10-25T22:41:20.3487326Z: 10.25.2022 22:41:20Z
Xamarin.Messaging.Integration.State.ServerStateContext Information: 0 : !Checking SSH configuration...: 10.25.2022 22:41:20Z
  DateTime=2022-10-25T22:41:20.3487326Z: 10.25.2022 22:41:20Z
Xamarin.Messaging.Ssh.SshCommandRunner Warning: 0 : Failed to execute 'grep "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDRpqma2f+6ghu6P2/Jxx2Aj6+4kY/1tFpkvM1CdlscbvESZFsYakl90P9YvXQhHTXhK6QUHgj4E9s+Ze4PxmXSfYd7b3imWpbSOIqWrlC4rfMn31F3EyJ60Cpc9DO15MtiVS9ctTWBKXzRU8NbUlek8LppEID5Xv0nEroryNHEzINXSvyhmTyUHAOklTjm3NVpqLrbGbFw9d6+F8pVskWtYyfFVl9PuW0EhbVox9inWGQIzbCMdVzjGb5M3ua/taNtTz8W6hsUQm8SB7UANR36klHUIWYmSQ5ZgyIkCZ7x6pNyRL2sr6UtFAfsp+vnGsIzakKHvZDXz7uBnRl6/Z7f steve@Stefans-MacBook-Pro.local" "/Users/steve/.ssh/authorized_keys"': ExitStatus = 1: 10.25.2022 22:41:25Z
  DateTime=2022-10-25T22:41:25.3448659Z: 10.25.2022 22:41:25Z
Xamarin.Messaging.Integration.State.ServerStateContext Information: 0 : Checking host configuration for connecting to 'macbook.lan'...: 10.25.2022 22:41:25Z
  DateTime=2022-10-25T22:41:25.4160488Z: 10.25.2022 22:41:25Z
Xamarin.Messaging.Integration.State.ServerStateContext Information: 0 : !Checking host configuration for connecting to 'macbook.lan'...: 10.25.2022 22:41:25Z
  DateTime=2022-10-25T22:41:25.4160488Z: 10.25.2022 22:41:25Z
Xamarin.Messaging.Integration.State.ServerStateContext Information: 0 : Server State transition from ConfiguringState to DisconnectingState on macbook.lan (192.168.178.27): 10.25.2022 22:41:25Z
  DateTime=2022-10-25T22:41:25.4275618Z: 10.25.2022 22:41:25Z
Xamarin.Messaging.Integration.State.ServerStateContext Information: 0 : Starting disconnection from macbook.lan...: 10.25.2022 22:41:25Z
  DateTime=2022-10-25T22:41:25.4315733Z: 10.25.2022 22:41:25Z
Xamarin.Messaging.Integration.State.ServerStateContext Information: 0 : !Starting disconnection from macbook.lan...: 10.25.2022 22:41:25Z
  DateTime=2022-10-25T22:41:25.4315733Z: 10.25.2022 22:41:25Z
Xamarin.Messaging.Integration.State.ServerStateContext Information: 0 : Server State transition from DisconnectingState to DisconnectedState on macbook.lan (192.168.178.27): 10.25.2022 22:41:25Z
  DateTime=2022-10-25T22:41:25.4591158Z: 10.25.2022 22:41:25Z
Xamarin.Messaging.Integration.State.ServerStateContext Information: 0 : Starting disconnection from macbook.lan...: 10.25.2022 22:41:25Z
  DateTime=2022-10-25T22:41:25.4631158Z: 10.25.2022 22:41:25Z
Xamarin.Messaging.Integration.State.ServerStateContext Information: 0 : !Starting disconnection from macbook.lan...: 10.25.2022 22:41:25Z
  DateTime=2022-10-25T22:41:25.4631158Z: 10.25.2022 22:41:25Z
Xamarin.Messaging.Integration.State.ServerStateContext Information: 0 : The connection to 'macbook.lan' has been finished: 10.25.2022 22:41:25Z
  DateTime=2022-10-25T22:41:25.4641170Z: 10.25.2022 22:41:25Z
Xamarin.Messaging.Integration.State.ServerStateContext Information: 0 : !The connection to 'macbook.lan' has been finished: 10.25.2022 22:41:25Z
  DateTime=2022-10-25T22:41:25.4641170Z: 10.25.2022 22:41:25Z
Xamarin.Messaging.Integration.State.ServerStateContext Error: 0 : An error occurred while trying to establish an SSH connection with SSH keys to '192.168.178.27:22'
Xamarin.Messaging.Integration.MessagingConfigurationException: An error occurred while trying to establish an SSH connection with SSH keys to '192.168.178.27:22' ---> System.IO.FileNotFoundException: Could not find file 'C:\Users\Stefan\AppData\Local\Xamarin\MonoTouch\id_rsa'.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   at Renci.SshNet.PrivateKeyFile..ctor(String fileName, String passPhrase)
   at Xamarin.Messaging.Ssh.MessagingAuthenticationMethod.InitializePrivateKeyAuthentication(String username, ISshInformationProvider sshInformationProvider) in D:\a\_work\1\s\src\Xamarin.Messaging.Ssh\MessagingAuthenticationMethod.cs:line 84
   at Xamarin.Messaging.Integration.State.ConfiguringState.<GetSshConnectionAsync>d__17.MoveNext() in D:\a\_work\1\s\src\Xamarin.Messaging.Integration\State\ConfiguringState.cs:line 193
   --- End of inner exception stack trace ---
   at Xamarin.Messaging.Integration.State.ConfiguringState.<GetSshConnectionAsync>d__17.MoveNext() in D:\a\_work\1\s\src\Xamarin.Messaging.Integration\State\ConfiguringState.cs:line 224
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Xamarin.Messaging.Integration.State.ConfiguringState.<GetSshConnectionAsync>d__15.MoveNext() in D:\a\_work\1\s\src\Xamarin.Messaging.Integration\State\ConfiguringState.cs:line 127
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Xamarin.Messaging.Integration.State.ConfiguringState.<OnExecutingAsync>d__14.MoveNext() in D:\a\_work\1\s\src\Xamarin.Messaging.Integration\State\ConfiguringState.cs:line 70: 10.25.2022 22:41:25Z
  DateTime=2022-10-25T22:41:25.4907201Z: 10.25.2022 22:41:25Z
Xamarin.Messaging.Integration.State.ServerStateContext Error: 0 : !An error occurred while trying to establish an SSH connection with SSH keys to '192.168.178.27:22': 10.25.2022 22:41:25Z
  DateTime=2022-10-25T22:41:25.4917191Z: 10.25.2022 22:41:25Z
System.Net.Mqtt.Sdk.ClientPacketListener Error: 0 : Client - An error occurred while listening and dispatching packets
System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
   at System.Net.Sockets.Socket.EndReceive(IAsyncResult asyncResult)
   at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult)
   --- End of inner exception stack trace ---
   at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult)
   at System.Threading.Tasks.TaskFactory`1.FromAsyncTrimPromise`1.Complete(TInstance thisRef, Func`3 endMethod, IAsyncResult asyncResult, Boolean requiresSynchronization): 10.25.2022 22:45:28Z
  DateTime=2022-10-25T22:45:28.6158613Z: 10.25.2022 22:45:28Z
System.Net.Mqtt.Sdk.ClientPacketListener Error: 0 : Client - An error occurred while listening and dispatching packets
System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
   at System.Net.Sockets.Socket.EndReceive(IAsyncResult asyncResult)
   at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult)
   --- End of inner exception stack trace ---
   at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult)
   at System.Threading.Tasks.TaskFactory`1.FromAsyncTrimPromise`1.Complete(TInstance thisRef, Func`3 endMethod, IAsyncResult asyncResult, Boolean requiresSynchronization): 10.25.2022 22:45:28Z
  DateTime=2022-10-25T22:45:28.6168613Z: 10.25.2022 22:45:28Z
System.Net.Mqtt.Sdk.MqttClientImpl Error: 0 : System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
   at System.Net.Sockets.Socket.EndReceive(IAsyncResult asyncResult)
   at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult)
   --- End of inner exception stack trace ---
   at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult)
   at System.Threading.Tasks.TaskFactory`1.FromAsyncTrimPromise`1.Complete(TInstance thisRef, Func`3 endMethod, IAsyncResult asyncResult, Boolean requiresSynchronization): 10.25.2022 22:45:28Z
  DateTime=2022-10-25T22:45:28.6188610Z: 10.25.2022 22:45:28Z
Xamarin.Messaging.Ssh.MessagingService Error: 0 : An error occurred on the underlying client while executing an operation. Details: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.: 10.25.2022 22:45:28Z
  DateTime=2022-10-25T22:45:28.6413821Z: 10.25.2022 22:45:28Z

The exception about the missing file is misleading. First of it does not exist but if you watch the folder during the connection process it gets created among with other files and when it fails it gets deleted again. So I am assuming that is a different error.
And ssh login to the machine and everything works fine. I can ssh into it and if you enable verbose login there are other commands as well as scp which are being executed just fine.
Has anyone encountered this problem and has a solution?
Visual Studio 2022
OSX Ventura with XCode 14.0.1 and Visual Studio 17.3.8 (build5)

zi8p0yeb

zi8p0yeb1#

It turns out that for a similar problem I encountered, the root cause was SSH-related due to Ventura and nothing to do with VS or Firewall.
This post described the problem and the solution.
macOS Ventura comes with OpenSSH_9.0p1 which disables by default the RSA signatures using SHA1 algorithm. If you read the release notes , you can find method to re-enable it, until Microsoft release update of the Xamarin pairing's SSH implementation.

Potentially-incompatible changes

This release disables RSA signatures using the SHA-1 hash algorithm by default. This change has been made as the SHA-1 hash algorithm is cryptographically broken, and it is possible to create chosen-prefix hash collisions for <USD$50K
For most users, this change should be invisible and there is no need to replace ssh-rsa keys. OpenSSH has supported RFC8332 RSA/SHA-256/512 signatures since release 7.2 and existing ssh-rsa keys will automatically use the stronger algorithm where possible.
This post describes how you may restart the SSHD without rebooting the machine.
I followed the steps and I have no more SSH related connection/pairing problem.

lztngnrs

lztngnrs2#

正如两条评论所指出的,由于Ventura附带了一个新的Openssh,我们需要添加一个变通方案,直到Xamarin修复了ssh连接过程。
在/etc/ssh/sshd_config中添加

HostkeyAlgorithms +ssh-rsa
PubkeyAcceptedAlgorithms +ssh-rsa

然后使用以下命令重新启动sshd:

launchctl stop com.openssh.sshd && launchctl start com.openssh.sshd
ylamdve6

ylamdve63#

您可以检查您的防火墙是否允许通过端口22(SSH的默认端口)传入连接,并检查您在Mac上使用的IP地址是否正确,您可以在Mac上的“系统首选项”〉“共享”〉“远程登录”中找到该IP地址。然后您可以检查SSH服务器是否可以正常连接,您可以参考Xamarin.iOS官方文档中的步骤。

相关问题