Visual Studio 2022 won't connect via SSH on macOS after upgrading to Ventura
Asked Answered
D

5

28

I have a working setup with Visual Studio 2022 17.3.6 on a Windows laptop and Mac M1 running macOS 12.6.1. When I run an Uno project or a Xamarin project it connects as expected to the Mac. I just upgraded the Mac to Ventura and am no longer able to connect. I understand the only thing that has changed is moving to Ventura, but am stuck on how to proceed.

The exact error is:

An error occurred while trying to establish an SSH connection with SSH keys to 'ip:22'

I have tried the following:

  • SSH from my laptop in Ubuntu for Windows- worked
  • SSH from another computer- worked
  • Verified Remote Login settings on Mac
  • Ran ssh username@macip 'ls' and it worked
  • Deleted %LOCALAPPDATA%\Xamarin\Monotouch - no change
  • Reviewed Visual Studio log- no additional information
  • Reviewed log on Mac and no additional information
Derail answered 27/10, 2022 at 1:43 Comment(1)
I simply upgraded my Visual Studio from I wanna say v17.4.x to v17.7.0 (both preview) and my SSH connection started working again. Like you it stopped working after I updated to Ventura on the Mac. In upgrading to Ventura I also updated Xcode and VS for Mac before I noticed SSH wasn't working anymore.Jabin
A
40

One reason could be the fact that Ventura comes with OpenSSH_9.0p1. Starting with OpenSSH v8.8, RSA signatures using SHA-1 are disabled:

This release disables RSA signatures using the SHA-1 hash algorithm by default”.

Fix SSH(RSA SHA-1) not working in macOS Ventura

  1. edit /etc/ssh/sshd_config and save it:

    HostkeyAlgorithms +ssh-rsa
    PubkeyAcceptedAlgorithms +ssh-rsa
    
  2. reboot sshd

macOS Monterey and older versions used OpenSSH v8.6 or older, respectively.

Aceous answered 27/10, 2022 at 4:45 Comment(11)
Editing sshd_config as monagano suggested should work, but if you have no permissions to edit sshd_config, try with sudo nano -w /etc/ssh/sshd_config I had to restart afterward, and then it worked.Chiou
I used this from superuser.com/questions/1488060/… :sudo launchctl unload /System/Library/LaunchDaemons/ssh.plist sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plistDerail
This didn't work until I deleted %LOCALAPPDATA%\Xamarin\Monotouch and then restarted visual studio 2022.Fico
HostkeyAlgorithms +ssh-rsa PubkeyAcceptedAlgorithms +ssh-rsa After adding this 2 lines also its not working.Phyfe
thanks, worked for me, after doing steps above + deleting %LOCALAPPDATA%\Xamarin\Monotouch pathUnpredictable
confirm that worked for me too: change the sshd_config + delete the LOCALAPPDATAInexperience
I edited the sshd_config file and put the two lines at the end of the file. I also rebooted the machine. After this, I get the error of "Couldn't retrieve SSH Fingerprint. Please ensure the host is reachable and Remote Login is enabled". I tried the troubleshooting here: learn.microsoft.com/en-us/xamarin/ios/get-started/installation/… , and when I get to the test the ssh portion I get this error: "kex_exchange_identification: read: Connection reset". Any suggestions?Protection
Worked for me as well after changing the sshd_config file, restarting the Mac, closing Visual Studio, deleting %LOCALAPPDATA%\Xamarin\Monotouch, starting Visual Studio again.Doublestop
@WadeBaird Confirm that you do not have a typo in the changes that you made to your sshd_config file. In my case, I fat fingered it and entered _ssh-rsa instead of +ssh-rsaRoderica
Obviously I was unable to read the instructions carefully...I added the two lines to ssh_config instead of sshd_config file ...took me some time to figure that out. Thanks for the help!Fitzwater
This fixed it for me, initially I put ras rather than rsa and then spent another hour trying other solutions before noticing my mistake.Monserratemonsieur
D
2

I'd argue that a more appropriate fix would be to install a newer version of OpenSSH for Windows rather than re-enabling defunct RSA SHA-1 signatures on the Mac side. Granted, v9.1.0.0p1 was not available until December 2022 after other answers were posted:

  1. On the Windows machine, open "Optional features"
  2. Search for the "OpenSSH Client" and expand it
  3. Click the "Uninstall" button
  4. Download and install OpenSSH for Windows v9.1.0.0p1 or greater

I have found that Visual Studio will implicitly use the new version and you'll be able to connect to the Mac again.

Destalinization answered 15/2, 2023 at 20:56 Comment(2)
Taylor Buchanan's answer should be #1 answer. (most other answers downgrade security on the Mac, which is not what you want). Additional remark: you can use winget to install the latest openssh: github.com/PowerShell/Win32-OpenSSH/wiki/Install-Win32-OpenSSHTryst
My Visual Studio not implicitly use the new version. How to make the VS use the new version?Variform
R
1

I've tried @monogano answer and it dit not work for me.

I've added the same lines :

HostkeyAlgorithms +ssh-rsa
PubkeyAcceptedAlgorithms +ssh-rsa

at the end of the /etc/ssh/ssh_config file (without restarting anything) and now my ssh connections are working again.

EDIT :

To keep the configuration between updates and so on, one must create a new file in /etc/ssh/ssh_config.d with the same lines as all files from this directory are included in /etc/ssh/ssh_config

Rhyne answered 15/11, 2022 at 12:30 Comment(0)
H
1

This concerns all OS Ventura system (eg. Terminal and Iterm) and not only VS. After ssh -vvv [my_concerned_host] I could see at the end of the report send_pubkey_test: no mutual signature algorithm. Then. SSH switch automatically to the next authentication method: password

For me applying @TylerH workaround in root ssh config was not enough. I also had to do it in my (profile) config : ~/.ssh/config + source ~/.bash_profile for applying changes. As they (already) said in 03/21 [Here] (https://confluence.atlassian.com/bitbucketserverkb/ssh-rsa-key-rejected-with-message-no-mutual-signature-algorithm-1026057701.html), RSA now offers too much vulnerabilities. **The patch in sshd_config should only be applied by people who can't regenerate Keys pair with a stronger algorithm ** (eg. ECDSA or ED25519)

If you have multiple hosts the 2 added lines must be preceded bye : Host *

Host *
  HostkeyAlgorithms +ssh-rsa
  PubkeyAcceptedAlgorithms +ssh-rsa
Heidt answered 16/11, 2022 at 12:47 Comment(1)
Thank you! Modifying /etc/ssh/sshd_config in my case was not enough and I additionally needed to add this and it worked right after.Hoahoactzin
H
1

The issue is caused because Ventura comes with OpenSSH_9.0p1 which disables RSA signatures with SHA-1 by default. That means that ssh-ing to any server using RSA signatures with SHA-1 will not work (affecting many old servers). I've finally managed to fix it. This solution works immediately without need to restart ssh, and is persistent even after you update macOS. To fix the problem:

Step 1: Go to /etc/ssh/ssh_config.d

sudo cd /etc/ssh/ssh_config.d

Step 2: Create a new file called config:

sudo nano config

Step 3: Add the following and save the file (Ctrl-O then Ctrl-X)

HostkeyAlgorithms +ssh-rsa
PubkeyAcceptedAlgorithms +ssh-rsa

You should be able to connect via SSH now.

Hungry answered 12/3, 2023 at 19:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.