gpt4 book ai didi

VS Code Remote SSH Connection not working(VS代码远程SSH连接不起作用)

转载 作者:bug小助手 更新时间:2023-10-24 19:45:17 28 4
gpt4 key购买 nike



Im trying to setup vscode with the remote developement extensions on a second pc. While it works on my main one it doesnt on the second one. Tried reinstalling vscode, extensions and using older versions but nothing works.

我正试图在另一台PC上安装带有远程开发扩展的vscode。虽然它在我的主计算机上有效,但在第二个计算机上不起作用。尝试重新安装vscode、扩展和使用旧版本,但都不起作用。


When trying to connect it cancels after chosing the os. So I cant even type in the password.
I set it up in the exact same way as with the other pc.

当尝试连接时,在选择操作系统后取消。所以我连密码都打不进去。我用与另一台PC完全相同的方式进行设置。


Any ideas?

有什么主意吗?


[20:32:53.595] [email protected]
[20:32:53.595] win32 x64
[20:32:53.596] SSH Resolver called for "ssh-remote+ssh.blabla", attempt 1
[20:32:53.597] SSH Resolver called for host: ssh.blabla
[20:32:53.597] Setting up SSH remote "ssh.blabla"
[20:32:53.610] Using commit id "58bb7b2331731bf72587010e943852e13e6fd3cf" and quality "stable" for server
[20:32:53.612] Install and start server if needed
[20:32:54.639] Checking ssh with "ssh -V"
[20:32:54.686] > OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5

[20:32:54.691] Running script with connection command: ssh -T -D 52819 ssh.blabla bash
[20:32:54.694] Terminal shell path: C:\WINDOWS\System32\cmd.exe
[20:32:54.758] >
]0;C:\WINDOWS\System32\cmd.exe
[20:32:54.758] Got some output, clearing connection timeout
[20:32:54.785] >
[20:32:55.045] > root@blabla's password:
[20:32:55.045] Showing password prompt
[20:32:57.596] "install" terminal command done
[20:32:57.597] Install terminal quit with output: root@blabla's password:
[20:32:57.597] Received install output: root@blabla's password:
[20:32:57.598] Stopped parsing output early. Remaining text: root@blabla's password:
[20:32:57.598] Failed to parse remote port from server output
[20:32:57.603] Resolver error: Error:
at Function.Create (c:\Users\Manuel.vscode\extensions\ms-vscode-remote.remote-ssh-0.55.0\out\extension.js:1:130564)
at Object.t.handleInstallOutput (c:\Users\Manuel.vscode\extensions\ms-vscode-remote.remote-ssh-0.55.0\out\extension.js:1:127671)
at I (c:\Users\Manuel.vscode\extensions\ms-vscode-remote.remote-ssh-0.55.0\out\extension.js:127:106775)
at processTicksAndRejections (internal/process/task_queues.js:94:5)
at async c:\Users\Manuel.vscode\extensions\ms-vscode-remote.remote-ssh-0.55.0\out\extension.js:127:104774
at async Object.t.withShowDetailsEvent (c:\Users\Manuel.vscode\extensions\ms-vscode-remote.remote-ssh-0.55.0\out\extension.js:127:109845)
at async Object.t.resolve (c:\Users\Manuel.vscode\extensions\ms-vscode-remote.remote-ssh-0.55.0\out\extension.js:127:107960)
at async c:\Users\Manuel.vscode\extensions\ms-vscode-remote.remote-ssh-0.55.0\out\extension.js:127:141955
[20:32:57.606] ------




[20:32:59.376] Password dialog canceled
[20:32:59.376] "install" terminal command canceled```

更多回答

For me deleting the Code folder and restarting the VS Code worked. stackoverflow.com/questions/47689536/…

对于我来说,删除代码文件夹并重新启动VS代码起作用了。STACKOVERFLOW.com/Questions/47689536/…

优秀答案推荐

Depending on the system you are in, when you first try to connect, a vscode-server will be set up and configured on your server.

根据您所在的系统,当您第一次尝试连接时,将在您的服务器上设置和配置vscode服务器。


In linux that can be in /Home/<user>/.vscode-server

在Linux中,它可以位于/Home/ /.vscode-server中


If you are on windows, check what that is.

如果你用的是Windows,检查一下那是什么。


The first solution is to try the extension command: Remote-SSH: kill VS Code Server on Host

第一个解决方案是在主机上尝试扩展命令:Remote-SSH:KILL vs Code Server


Open the command pallet (CTRL + SHIFT + P or COMMAND + SHIFT + P (mac) ).

打开命令面板(CTRL+SHIFT+P或COMMAND+SHIFT+P(Mac))。


And type Remote kill :

然后键入Remote kill:


enter image description here


Then try to connect again! (That will kill the server on the host! Which will make it start again on the next try)

然后尝试再次连接!(这将杀死主机上的服务器!这将使它在下一次尝试时再次启动)


If that doesn't work, and things are still failing:

如果这不起作用,而且事情仍然在失败:


Delete, rm


Then a good solution that can work is: to connect to your server through terminal (vscode terminal, gnome-terminal, whatever). Then go and remove /Home/<user>/.vscode-server

那么一个可以工作的好解决方案是:通过终端(vscode终端、GNOME终端,随便什么)连接到您的服务器。然后,转到并删除/Home/ /.vscode-server


Try to connect after that. At the attempt the server will be re-installed completely anew, chances are it will work. (I did that and it worked for me, so whatever that was going wrong on the vscode-server: just start all over)

在那之后试着联系一下。在尝试时,服务器将被完全重新安装,它很有可能会正常工作。(我这样做了,对我来说很管用,所以无论vscode服务器上出了什么问题:都要重新开始)


But again: you will lose things, config, meta data, etc. (because you start anew).

但再说一次:你会丢失一些东西、配置、元数据等(因为你重新开始)。


Update:


As stated by @natevw in the comments:

正如@Natevw在评论中所说的那样:



I found that removing only the .vscode-server/bin subfolder helped straighten things out and afaict kept my data/settings.



Removing only vscode-server/bin seems to work well, and the config, metadata, etc. remains untouched.

仅删除vscode-server/bin似乎运行良好,配置、元数据等保持不变。



I downgrade Remote-SSH plugin to 0.51.0, rm -rf $HOME/.vscode-server on the remote machine. Connect again, VSCode will download and install a new .vscode-server. Then upgrade Remote-SSH plugin, everything works.

我将远程机器上的Remote-SSH插件降级为0.51.0,rm-rf$HOME/.vscode-server。再次连接,VSCode将下载并安装新的.vscode服务器。然后升级远程SSH插件,一切正常。



One way worked for me is, by adding this line in the vscode settings (JSON) file.

对我有效的一种方法是,在vscode设置(JSON)文件中添加此行。


"remote.SSH.useLocalServer": false

“emote.SSH.useLocalServer”:FALSE


VSCode settings



I met the same problem. After I did these steps, it works:

我也遇到了同样的问题。在我完成这些步骤后,它起作用了:


on the remote server:

在远程服务器上:


rm -rf ~/.vscode-server  
rm -rf ~/.vscode

On the local VS code:

在本地VS代码上:


reinstall remote-ssh


In case all the above fails, here's how I fixed my issue.

如果以上所有方法都失败了,下面是我修复问题的方法。


First, I was able to SSH into my remote server (Ubuntu 22.04, Raspberry Pi 4, arm64) using a simple bash terminal. So I logged in using my terminal (macOS), and I went to

首先,我能够使用一个简单的bash终端通过SSH连接到我的远程服务器(Ubuntu22.04,Raspberry PI 4,arm64)。所以我用我的终端(MacOS)登录,然后我去了


cd $HOME/.vscode-server/bin/WHATEVER-HASH-YOU-HAVE/

In this directory, there is a file named server.sh. I tried running this script, and I got the following error:

在这个目录中,有一个名为server.sh的文件。我试着运行这个脚本,得到了以下错误:


./node: error while loading shared libraries: libatomic.so.1: cannot open shared object file: No such file or directory

The issue was clear: there was a missing shared library on my system. Either Node.js now requires that or the new version of the SSH-Remote extension; I don't know. I did not spent the time to dig into those specifics.

问题很明显:我的系统上缺少一个共享库。或者Node.js现在需要它,或者是新版本的SSH-Remote扩展;我不知道。我没有花时间去深入研究这些细节。


But to fix that, I simply did:

但为了解决这个问题,我干脆这么做了:


sudo apt-get install libatomic1

That installed the missing shared library.

安装了缺少的共享库。


After that, I delete $HOME/.vscode-server:

之后,我删除$HOME/.vscode-server:


rm -rf $HOME/.vscode-server

and tried again connecting using VSCode. It worked!

并再次尝试使用VSCode进行连接。啊,真灵!


Hope this can help someone like me, for whom all other options failed.

希望这能帮助像我这样的人,对他们来说,所有其他选择都失败了。



Issue: while trying to ssh connect to Linux(remote machine) using vscode.

问题:尝试ssh时使用vscode连接到Linux(远程计算机)。


Solution: remove/delete the bin folder inside .vscode-server and then reconnect to the remote machine

解决方案:移除/删除.vscode-server内的bin文件夹,然后重新连接到远程计算机


In remote server:


remote_name:~$ rm -rf ~/.vscode-server/bin

*reconnect to remote machine*


To add what @cagriyonca mentioned, delete the ip that is in the file located in Windows in:

要添加@cagriyonca提到的内容,请删除位于以下位置的Windows文件中的IP:


C:\Users\<YourUsername>\.ssh\known_hosts

This worked for me

这对我很管用



It turns out that my fish was a obstacle for vscode server.

事实证明,我的鱼是vscode服务器的障碍。


Then I tried

然后我试着


chsh -s /bin/bash

And works fine.

而且工作得很好。



I had this exact same issue. Nothing seemed to work (uninstall extension, uninstall VSCode, delete a bunch of cache folders, etc). SSH through terminal was working, but not on VSCode.

我也有同样的问题。似乎什么都不起作用(卸载扩展、卸载VSCode、删除一堆缓存文件夹等)。通过终端的SSH工作正常,但在VSCode上不起作用。


After working a bit on the terminal I got an error for no empty space, so deleting a bunch of files on the server was the solution for me, it was nothing related to VSCode.

在终端上工作了一会儿后,我收到了一个错误,因为没有空白,所以删除服务器上的一堆文件是我的解决方案,这与VSCode无关。



Stumbled upon this situation today. Switching to Pre-Release Version for my Remote-SSH extension worked.

今天偶然发现了这种情况。切换到我的远程SSH扩展的预发布版本工作。



I worked adding \\ in the path of the .config

我在.config的路径中添加了


I share the steps

我和你分享这些步骤



  • Go to .config settings

    转到.config设置



  • select configuration

    选择配置



  • add double \\

    添加双精度\\






Just deleted old host information from ssh settings file and problem solved.

刚刚从ssh设置文件中删除了旧的主机信息,问题解决了。



I had faced this issue when I tried to connect to a Linux server from a windows laptop.
It was using the wrong fingerprint.
It worked for me after removing the line related to that server from $HOME/.ssh/known_hosts

当我试图从一台Windows笔记本电脑连接到一台Linux服务器时,我就遇到了这个问题。它用的是错误的指纹。在从$HOME/.ssh/KNOWN_HOSTS中删除与该服务器相关的行后,它对我起作用



I ran into the same issue, it got fixed when I updated the path of the IdentityFile from 'ssh_key' to '~/.ssh/ssh_key' (the entire path I mean) so that the VS code could recognize it.

我遇到了同样的问题,当我将标识文件的路径从‘ssh_key’更新为‘~/.ssh/ssh_key’(我指的是整个路径),以便VS代码可以识别它时,它得到了修复。



Restart remote machine worked for me (after trying all the previous answers with no luck).

重新启动远程计算机对我有效(在尝试了前面的所有答案但都没有成功)。



Giving you the oldest trick of the book:

告诉你这本书中最古老的诀窍:


restart

It worked for me and I laughed hysterically for exactly 57 seconds. Happy reconnecting to the server my dear Coder!

这对我很有效,我歇斯底里地笑了57秒。很高兴重新连接到服务器,我亲爱的Coder!



I could not connect to the server, my issue was the remote server was full

我无法连接到服务器,我的问题是远程服务器已满


check with the command df -h if the disk is full !

如果磁盘已满,请使用命令df-h进行检查!



In my case I needed to remove arm_64bit=1 from config.txt (/boot/config.txt).

在我的例子中,我需要从config.txt(/ot/config.txt)中删除ARM_64bit=1。



I had previously tried to get vs code working on the remote machine.
I deleted both the home/.vscode-server AND the .vscode directories. These dirs were NOT deleted by uninstalling vs code on the remote machine

我之前曾尝试让VS代码在远程机器上运行。我删除了home/.vscode-server和.vscode目录。卸载远程计算机上的VS代码不会删除这些目录


This also might help. I set the debug level by adding "logLevel DEBUG3" on the .ssh config file in VSCode

这也可能有所帮助。我通过在VSCode的.ssh配置文件中添加“logLevel DEBUG3”来设置调试级别


The logs are were very hard for me to find and are not named as the terminal output says they are (long hex string .log). I finally found it them in C:\Users<user>\AppData\Roaming\Code\logs they can be found by using command Developer:Open logs folder. There you will find subfolders named windowx. Under the window where the error occurred (you just have to look in by time) find exthot/output_logging_xxxxx/remote - ssh.log.

日志对我来说非常难找到,并且没有像终端输出所说的那样命名(长十六进制字符串.log)。我终于在C:\USERS \AppData\Roaming\Code\Logs中找到了它们,可以使用命令Developer:Open Logs文件夹找到它们。在那里,您将找到名为windowx的子文件夹。在发生错误的窗口(您只需按时间查看)下,找到exthot/OutputLogging_xxxxx/Remote-ssh.log。



In my situation i tried all other answers that were given in this thread, None worked. I could manually ssh through the command line but I could not connect through Connect to Host... option.

在我的情况下,我尝试了这个帖子中给出的所有其他答案,都没有奏效。我可以通过命令行手动ssh,但无法通过连接到主机进行连接...选择。


My solution was to connect to the VPN of my company (since this is a work related topic)

我的解决方案是连接到我公司的VPN(因为这是一个与工作相关的话题)



In my case (Rocky9 minimal install) the "tar" utility was not installed.
After I installed tar (dnf install tar) it starts working.
The error message produces by installer is quite misleading.

在我的例子中(Rocky9最小安装),没有安装“tar”实用程序。在我安装TAR(DnF安装TAR)之后,它开始工作。安装程序产生的错误消息非常具有误导性。



For me, turned out it was a issue with the .pem file

对我来说,原来是.pem文件有问题


After testing all solutions above, I figured out the .shh/config file was using IdentityFile without the complete path. So, I added the complete path on the config file such as:

在测试了上面的所有解决方案之后,我发现.shh/config文件使用的是没有完整路径的标识文件。因此,我在配置文件中添加了完整路径,如下所示:


Host your-alias
HostName ec2-xx-yy-zz.compute-1.amazonaws.com
IdentityFile C:\Users\your-user\folder\ec2-pem-file.pem
User ubuntu

When prompting the error "Could not establish connection", I checked on the log (VS Code Output tab) the "no such identity" message just before the "[20:32:57.603] Resolver error: Error: " message.

当提示错误“无法建立连接”时,我在日志(VS代码输出选项卡)上检查了“没有这样的身份”消息,就在“[20:32:57.603]Resolver Error:Error:”消息之前。



The previous answers may not be sufficient if your SSH host server lacks SSD capacity.

如果您的SSH主机服务器缺少SSD容量,则前面的答案可能不够充分。


If you have tried all the above solutions and they have not worked for you, check if your host server has enough capacity to accommodate ./vscode-server. In my case, after deleting large files from my server, I was able to effectively use SSH.

如果您已经尝试了上述所有解决方案,但它们都不适用于您,请检查您的主机服务器是否有足够的容量来容纳。/vscode-server。在我的例子中,在从我的服务器删除大文件之后,我能够有效地使用SSH。



For me the issue was that ~/.bashrc on my remote server contained an erroneous 'exit' that was supposed to execute only during non-interactive sessions, to avoid terminal output during scp commands.

对我来说,问题是我的远程服务器上的~/.bashrc包含一个错误的“出口”,应该只在非交互会话期间执行,以避免在SCP命令期间输出终端。


I had implemented that solution successfully on another server though. Not sure why it broke the second one. Both are CentOS 7, but different patch levels.

不过,我已经在另一台服务器上成功实现了该解决方案。不知道为什么它弄坏了第二个。两者都是CentOS 7,但补丁级别不同。


Removed the exit statement and now remote-ssh works great.

删除了EXIT语句,现在Remote-ssh运行得很好。


# .bashrc
# ...
if [[ $- == *i* ]]
then
:
else
exit # <--- Culprit
fi
# Other stuff useful only for interactive shells.

I had found this solution here: https://unix.stackexchange.com/questions/26676/how-to-check-if-a-shell-is-login-interactive-batch but now starting to doubt it?

我在这里找到了这个解决方案:https://unix.stackexchange.com/questions/26676/how-to-check-if-a-shell-is-login-interactive-batch,但现在开始怀疑它?



On the remote server, you run this command below. After that, the VScode window should be reloaded and you connect to the remote via SSH again.

在远程服务器上,运行下面的命令。之后,应重新加载VScode窗口,并再次通过SSH连接到遥控器。


rm -rf $HOME/.vscode-server


I tried below steps in host terminal and issue was resolved.

我在主机终端尝试了以下步骤,问题得到了解决。


cd .vscode-server/bin/

cd b3e4e68a0bc097f0ae7907b217c1119af9e03435/ (this folder name can be different for you)

tar -zxvf vscode-server.tar.gz

mv vscode-server-linux-x64/* .

rm -rf vscode-server-linux-x64/ vscode-server.tar.gz

touch 0


Here is an alternative for Remote SSH, pls check my answer at: https://stackoverflow.com/a/68046111/13089935

以下是远程SSH的替代方案,请查看我的答案:https://stackoverflow.com/a/68046111/13089935


TLDR:

TLDR:


We can use a web-based VS Code that is installed on the server directly.

我们可以使用直接安装在服务器上的基于Web的VS代码。


更多回答

Hi, how do I open this window where I type remote kill please?

你好,请问我如何打开这个窗口,在那里我可以输入远程删除?

Hi, It's the command pallet. You can do that with CTRL + SHIFT + P (or COMMAND + SHIFT + P in mac)

嗨,我是指挥部的托盘。可以使用Ctrl+Shift+P组合键(或者Mac中的Command+Shift+P组合键)

That is really helpful. Been searching the solution for days and glad that I pondered on your solution. But may I know why do we have to kill VS code server?

这真的很有帮助。我已经寻找了几天的解决方案,很高兴我考虑了你的解决方案。但我能知道为什么我们要杀了VS代码服务器吗?

I found that removing only the .vscode-server/bin subfolder helped straighten things out and afaict kept my data/settings.

我发现只删除.vscode-server/bin子文件夹有助于理顺问题,而AFAICT保留了我的数据/设置。

rm /Home/<user>/.vscode-server worked for me. Thanks

Rm/Home//.vscode-服务器适用于我。谢谢

This worked for me as well.. I was able to ssh through command prompt, delete the .vscode-server file in home and tried ssh through VSCode and it worked... Thanks!!

这对我也很管用..我能够通过命令提示符ssh,在家里删除.vscode-server文件,并通过VSCode尝试ssh,它起作用了……谢谢!!

Thanks a lot. This saved me a lot of trouble!

非常感谢。这给我省了不少麻烦!

That didnt work for me.

这对我不起作用。

Worked for me without even downgrading! only removed the dir on the host and tried connecting again.

为我工作,甚至没有降级!仅删除了主机上的目录并尝试再次连接。

This fixed for me. After the first connection I removed this setting and it kept working

这是为我准备的。在第一次连接后,我删除了此设置,但它仍在工作

For me it leads to: Received install output: /bin/sh: 1: ssh: not found

对我来说,它指向:已接收安装输出:/bin/sh:1:ssh:Not Found

Thank you sir! I banged my head for hours for not being able to connect to a host I previously connected.

谢谢你,先生!我因为无法连接到之前连接的主机而苦恼了几个小时。

I was getting the following errors prior to being prompted for ssh key (or password). Removing known_hosts did the trick. "getsockname failed: bad file descriptor" "got some output, clearing connection timeout" "channel_send_open: channel 2: unexpected internal error" "the process tried to write to a nonexistent pipe"

在提示输入ssh密钥(或密码)之前,我收到了以下错误。删除已知主机起到了作用。“getsockname失败:文件描述符错误”“已获得一些输出,正在清除连接超时”“CHANNEL_SEND_OPEN:CHANNEL 2:意外内部错误”“进程尝试写入不存在的管道”

Thank you sir <3 That was also my issue it seems!

谢谢你,先生<3这似乎也是我的问题!

Is there a way to use ssh with fish as a default shell?

有没有办法将ssh与Fish一起使用作为默认的外壳?

@Yatin Not anymore for what person? I still can not see the question.

@雅婷不再为什么人服务了?我还是看不出这个问题。

The answer doesn't have formatting issues anymore..

答案不再有格式问题。

This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. To get notified when this question gets new answers, you can follow this question. Once you have enough reputation, you can also add a bounty to draw more attention to this question. - From Review

这并没有真正回答这个问题。如果您有不同的问题,可以通过单击提问来提问。要在此问题获得新答案时收到通知,您可以按照此问题进行操作。一旦你有了足够的声誉,你也可以添加赏金来吸引更多的人关注这个问题。-摘自评论

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com