iT邦幫忙

0

VS Code Remote SSH 連不上

要用 ssh 遠端連線至用Virtualbox安裝的 Ubuntu ,但 VSCode 會一直很囉唆地要我選伺服器種類,我在別的地方的電腦不會詢問這個問題。
https://ithelp.ithome.com.tw/upload/images/20200421/20114276g8TR7NSctD.png

選了之後然後有時候可以連上有時候會直接跳以下錯誤:
https://ithelp.ithome.com.tw/upload/images/20200421/20114276vqd3LKFVJp.png

然後 VSCode 的終端機內印出的訊息如下:

> 
> 
> 
[00:20:25.947] > username@192.168.1.99's password: 
[00:20:25.947] Showing password prompt
[00:20:29.822] Got password response
[00:20:29.822] "install" wrote data to terminal: "********"
[00:20:29.834] > 
> 
[00:20:29.862] > ccc0cb9fe625: running
> 
[00:20:29.880] > Acquiring lock on /home/username/.vscode-server/bin/ff915844119ce9485abfe8aa9076ec7
> 6b5300ddd/vscode-remote-lock.iskku.ff915844119ce9485abfe8aa9076ec76b5300ddd     
> 
[00:20:29.889] > \ln /home/username/.vscode-server/bin/ff915844119ce9485abfe8aa9076ec76b5300ddd/vsco
> de-remote-lock.iskku.ff915844119ce9485abfe8aa9076ec76b5300ddd.target /home/username
> /.vscode-server/bin/ff915844119ce9485abfe8aa9076ec76b5300ddd/vscode-remote-lock.
> username.ff915844119ce9485abfe8aa9076ec76b5300ddd
> Found existing installation at /home/username/.vscode-server/bin/ff915844119ce9485a
> bfe8aa9076ec76b5300ddd...
> 
[00:20:29.897] > Found running server...
> 
> *
> * Reminder: You may only use this software with Visual Studio family products, 
> * as described in the license (https://go.microsoft.com/fwlink/?linkid=2077057)
> *
> 
> 
[00:20:29.916] > Neither wget nor curl is installed
> ccc0cb9fe625##26##
> 
[00:20:29.916] Received install output: ccc0cb9fe625##26##
[00:20:29.916] Neither curl nor wget is installed - can't download the Server
[00:20:29.917] Resolver error: Downloading VS Code Server failed - please install either curl or wget on the remote.
[00:20:29.919] ------




[00:20:30.316] "install" terminal command done
[00:20:30.316] Install terminal quit with output: 

如果用一般終端機軟體可以正常透過ssh連上伺服器。
我有試過以下方法:

  • 移除家目錄內的 .vscode-server
  • 重新安裝 VSCode 及 Debian
  • 區網的另一台筆記型電腦 (Ubutnu) 安裝 VSCode 試著連看看
    但也是遇到同樣問題,這些電腦及虛擬機都可以正常連外網。
    VSCode只有安裝繁體中文插件與Remote-SSH插件兩樣而已

請問該怎麼排除呢?謝謝。

就是因為這樣的問題,才讓我放棄了vs code改用ide編輯器。
rew87516 iT邦新手 4 級 ‧ 2020-04-21 15:13:02 檢舉
你也有遇到相同的問題嗎?
我是用sshfs這個擴充套件,蠻好用的
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中
0
dragonH
iT邦超人 5 級 ‧ 2020-04-21 13:54:49

剛試了一下

模擬一下沒有網路會發生什麼事

不過我沒辦法建 vm

所以弄了兩台 ec2

分別放在 public subnet 跟 private subnet

然後利用 public 的那台當作 bastion 跳轉進去 private

結果也是正常可以用 vscode ssh 進去

所以有無網路應該是不會影響

或許你可以照他說的

檢查一下 curl 或者 wget 的安裝狀態

看更多先前的回應...收起先前的回應...
rew87516 iT邦新手 4 級 ‧ 2020-04-22 10:21:11 檢舉

結果我在Linux那邊安裝 wget 後還真的就能用了@@||

rew87516 iT邦新手 4 級 ‧ 2020-04-22 10:23:37 檢舉

感覺是ssh不知道為什麼不能用,所以只能用wget或是curl做替代方案。
所以伺服器端也要安裝這兩個套件(或是其一?)就能連。

dragonH iT邦超人 5 級 ‧ 2020-04-22 10:24:03 檢舉

rew87516

他用 wget 或 curl

應該只是為了裝 vscode server 而已吧

不過 ubuntu 預設應該有幫你裝好才對

/images/emoticon/emoticon01.gif

rew87516 iT邦新手 4 級 ‧ 2020-04-22 10:38:38 檢舉

我是用Debian,不過我把.vscode-server砍了,就算連不上它也會自動建立耶。
所以是VScode叫Debian建立.vscode-server,但是抓不回來的意思嗎?XD

dragonH iT邦超人 5 級 ‧ 2020-04-22 11:05:27 檢舉

rew87516

這也是有可能

也有可能是他只針對 wget 或 curl 失敗來 handle

沒對未安裝 handle

所以才會要裝兩個其中一個

我猜的

1
japhenchen
iT邦超人 1 級 ‧ 2020-04-22 08:48:41

我是不是老土了?還在用WinSCP+VSCODE在管理LINUX上的程式碼.....

dragonH iT邦超人 5 級 ‧ 2020-04-22 09:40:35 檢舉

vscode ssh 好用推推/images/emoticon/emoticon07.gif

rew87516 iT邦新手 4 級 ‧ 2020-04-22 10:41:18 檢舉

習慣順手就好啦~~~:D

0
wen1026
iT邦見習生 ‧ 2021-08-25 17:39:49

我遇過這個問題,透過編輯C:\User....ssh\config已經解決了!!
(以"ssh Amy@123.456.78.999 -p 22"為例)

config file格式應為:

Host MyHostName
    HostName 123.456.78.999
    User Amy
    Port 22

參考: https://stackoverflow.com/questions/68917798/could-not-establish-connection-to-hostname-remote-ssh-problem-in-vscode-c/68919495#68919495

0
easonc13
iT邦見習生 ‧ 2022-06-16 17:24:01

我有遇到,結果是主機的空間滿了,VSCode 無法安裝並開啟
所以就會跳這個錯誤

大家可以檢查看看

我要發表回答

立即登入回答