shellvisual-studio-codesshterminalvscode-remote

How to fix VS Code error with Remote-SSH: "the terminal process failed to launch: A native exception occurred during launch (forkpty(3) failed.)."?


I've installed and used the Remote-SSH extension in VS Code to access a Linux staging environment and work remotely.

The setup and connection works for one user, however is not allowing me to connect as a different user (on the same server).

Immediately after connecting, an error pops up saying the terminal process failed to launch: A native exception occurred during launch (forkpty(3) failed.). and the terminal would fail to open. If I attempt to manually open the terminal, it will fail with the same error.

Here is an example of how my Remote-SSH config file looks:

Host configfile1
  HostName host.website.com
  User username1
  IdentifyFile "[key file path]"

Host configfile2
  HostName host.website.com
  User username2
  IdentifyFile "[key file path]"

I could connect just fine and open remote terminal with configfile1, however would run into the aforementioned error when attempting to connect with configfile2.

I have tried various solutions mentioned in this GitHub issues thread, but to no avail: https://github.com/microsoft/vscode-remote-release/issues/4233

Does anybody have a solution for this?


Solution

  • I don't know the underlying causes for this, but this error pops up when using jailed shell settings.

    Try changing the user's SSH shell settings to normal shell, and you may be able to connect without an issue.

    This may not be ideal for all scenarios or security considerations, however, but it will allow Remote-SSH to connect and spawn the terminal.