简体   繁体   English

无法在 Mac 中使用 VS-Code 通过 SSH 连接到远程 GCP VM

[英]Unable to connect through SSH with VS-Code in Mac to a remote GCP VM

I have created a compute engine instance (Debian) in GCP with a public and private key and able to SSH it from my local mac using the command given below.我已经在 GCP 中使用公钥和私钥创建了一个计算引擎实例 (Debian),并且能够使用下面给出的命令从我的本地 mac 对其进行 SSH。

I have some folders and files in the remote machine which I would like to edit through VS-code (Version: 1.56.1) installed in my local.我在远程机器中有一些文件夹和文件,我想通过安装在本地的 VS 代码(版本:1.56.1)进行编辑。 But when I try to connect it through VS code as per the instructions in manual using this command但是当我尝试按照手册中的说明使用此命令通过 VS 代码连接它时

ssh -i ~/.ssh/<filename> username@ipaddress

在此处输入图像描述

I am getting the below error:我收到以下错误:

在此处输入图像描述

What can I try to fix it?我可以尝试解决什么问题?

It looks to be a specific error from VScode and Remote SSH extension.它看起来是来自 VScode 和远程 SSH 扩展的特定错误。 In some cases it worked when the time out value was increased and when the parameter useLocalServer was set to false ( remote.SSH.useLocalServer": false ) under VScode settings. Also try upgrading the version for VSCode and see if the issue mitigates.某些情况下,当超时值增加并且在VScode 设置下将参数 useLocalServer设置为 false ( remote.SSH.useLocalServer": false ) 时,它会起作用。还可以尝试升级 VSCode 的版本,看看问题是否得到缓解。

To edit folders and files in the remote machine through VS-code you can Connect to a remote host.要通过 VS-code 编辑远程机器中的文件夹和文件,您可以连接到远程主机。

Steps to connect to a remote host:连接远程主机的步骤:

  1. Verify you can connect to the SSH host by running the following command from a terminal.通过从终端运行以下命令,验证您可以连接到 SSH 主机。

     ssh user@hostname
  2. In VS Code, select Remote-SSH: Connect to Host, from the Command Palette and use the same user@hostname as in step 1.在 VS Code 中,select Remote-SSH:从命令面板连接到主机,并使用与步骤 1 中相同的用户@主机名

  3. If VS Code cannot automatically detect the type of server you are connecting to, you will be asked to select the type manually.如果 VS Code 无法自动检测您连接的服务器类型,您将被要求手动输入类型 select。

  4. After a moment, VS Code will connect to the SSH server and set itself up.片刻之后,VS Code 将连接到 SSH 服务器并自行设置。 VS Code will keep you up-to-date using a progress notification and you can see a detailed log in the Remote - SSH output channel. VS Code 将使用进度通知让您保持最新状态,您可以在远程 - SSH output 频道中查看详细日志。

  5. After you are connected, you'll be in an empty window.连接后,您将进入一个空的 window。 You can always refer to the Status bar to see which host you are connected to.您始终可以参考状态栏来查看您连接到的主机。

  6. You can then open any folder on the remote machine using File > Open.然后,您可以使用“文件”>“打开”打开远程计算机上的任何文件夹。 From here, install any extensions you want to use when connected to the host and start editing.从这里,安装连接到主机时要使用的任何扩展并开始编辑。

Refer Connect to remote host for information.有关信息,请参阅连接到远程主机

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM