Trouble connecting VS Code to remote Linux host due to key mismatch after host key regeneration

George Wilson 80 Reputation points
2026-10-06T16:16:30.5366667+00:00

Our developer is having trouble connecting VS Code to a remote Linux host because the host key was regenerated and is causing a key mismatch, so they don't have access to it right now. How do we edit the local known-hosts file to resolve this key mismatch?

Windows for business | Windows 365 Enterprise
0 comments No comments

1 answer

Sort by: Most helpful
  1. Chen Tran 13,355 Reputation points Independent Advisor
    2026-10-06T16:38:36.9833333+00:00

    Hello George,

    Thank you for positing question on Microsoft Windows Forum!Based on the issue description. This might be an SSH known_hosts problem, not a VS Code problem. VS Code Remote-SSH uses the local OpenSSH client, so you can repair the entry from PowerShell or a terminal and then reconnect.

    To resolve the SSH key mismatch caused by the regenerated host key, you can remove the outdated entry from the local known_hosts file by running the command ssh-keygen -R <remote_host_ip_or_hostname> in your local terminal to automatically remove the stale entry for the remote host's IP address or hostname. Then try to open VS Code and initiate the Remote-SSH connection to the host again.

    I hope you have found something useful here. If it helps you get more insight into the issue, it is appreciated to accept the answer. Should you have more questions, feel free to leave a message. Have a nice day!

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.