VSCode Remote-SSH Cannot Connect to my server - ssh

Recently I can not use Remote-SSH Connect to my server on Vscode editor.
And the detail message like this
> [19:13:42.444] Log Level: 2 [19:13:42.448] remote-ssh#0.50.0
> [19:13:42.448] win32 x64 [19:13:42.449] SSH Resolver called for
> "ssh-remote+140.122.184.164", attempt 1 [19:13:42.449] SSH Resolver
> called for host: 140.122.184.164 [19:13:42.449] Setting up SSH remote
> "140.122.184.164" [19:13:42.452] Acquiring local install lock:
> C:\Users\Acer\AppData\Local\Temp\vscode-remote-ssh-140.122.184.164-install.lock
> [19:13:42.464] Looking for existing server data file at
> c:\Users\Acer\AppData\Roaming\Code\User\globalStorage\ms-vscode-remote.remote-ssh\vscode-ssh-host-140.122.184.164-78a4c91400152c0f27ba4d363eb56d2835f9903a\data.json
> [19:13:42.464] Using commit id
> "78a4c91400152c0f27ba4d363eb56d2835f9903a" and quality "stable" for
> server [19:13:42.465] Install and start server if needed
> [19:13:42.468] Checking ssh with "ssh -V" [19:13:42.514] >
> OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5 [19:13:42.515] Checking ssh
> with "C:\WINDOWS\System32\OpenSSH\ssh.exe -V" [19:13:42.547] >
> OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5 [19:13:42.547] Checking ssh
> with "C:\Program Files\Git\usr\bin\ssh.exe -V" [19:13:42.581] >
> OpenSSH_8.1p1, OpenSSL 1.1.1d 10 Sep 2019 [19:13:42.583] askpass
> server listening on
> \\.\pipe\vscode-ssh-askpass-a5415762a34cef86c303cb95e6068cc83f77ad45-sock
> [19:13:42.583] Spawning local server with
> {"ipcHandlePath":"\\\\.\\pipe\\vscode-ssh-askpass-2f67c00bee72c5d0d1a3761b3a9ce7fa93226b8b-sock","sshCommand":"C:\\Program
> Files\\Git\\usr\\bin\\ssh.exe","sshArgs":["-v","-T","-D","52132","140.122.184.164"],"dataFilePath":"c:\\Users\\Acer\\AppData\\Roaming\\Code\\User\\globalStorage\\ms-vscode-remote.remote-ssh\\vscode-ssh-host-140.122.184.164-78a4c91400152c0f27ba4d363eb56d2835f9903a\\data.json"} [19:13:42.583] Local server env:
> {"DISPLAY":"1","ELECTRON_RUN_AS_NODE":"1","SSH_ASKPASS":"c:\\Users\\Acer\\.vscode\\extensions\\ms-vscode-remote.remote-ssh-0.50.0\\out\\local-server\\askpass.bat","VSCODE_SSH_ASKPASS_NODE":"C:\\Users\\Acer\\AppData\\Local\\Programs\\Microsoft
> VS
> Code\\Code.exe","VSCODE_SSH_ASKPASS_MAIN":"c:\\Users\\Acer\\.vscode\\extensions\\ms-vscode-remote.remote-ssh-0.50.0\\out\\askpass-main.js","VSCODE_SSH_ASKPASS_HANDLE":"\\\\.\\pipe\\vscode-ssh-askpass-a5415762a34cef86c303cb95e6068cc83f77ad45-sock"}
> [19:13:42.588] Spawned 4652 [19:13:42.675] > local-server> Spawned
> ssh: 7024 [19:13:42.701] stderr> OpenSSH_8.1p1, OpenSSL 1.1.1d 10 Sep
> 2019 [19:13:42.828] stderr> debug1: Server host key:
> ecdsa-sha2-nistp256 SHA256:Zs/tS7SoUebvH2cFNl3/myVG+/wSM2ET0ucLj6D9H00
> [19:13:43.042] Got askpass request:
> {"request":"Wendy#140.122.184.164's password: "} [19:13:43.042]
> Showing password prompt [19:13:43.043] Listening for interwindow
> password on
> \\.\pipe\vscode-ssh-askpass-517f0ea068bd7eb6da8a4c8052ea3b542e429ade-sock
> [19:13:43.043] Writing password prompt to globalState
I'm not sure what is the problem with it.
My server has a .vscode folder. Will the problem with it?
.vscode folder has settings.json like this
{
"git.ignoreLimitWarning": true
}
and the sftp.json file like this
> {
> "name": "Wendy",
> "host": "140.122.184.164",
> "protocol": "sftp",
> "port": 9600,
> "username": "Wendy",
> "remotePath": "/share/nas165/Wendy",
> "uploadOnSave": true }

Initailly, I could connect to a remote server with vscode but suddenly I couldn't connect.
I tried as much solutions as possible but finally I couldn't solve this kind of problem.
But I found this problem will be because of the ssh on windows because I tried to connect to a remote server using sublime with sftp but I also coundn't connect.
I think this is the windows weakpoint that is needed to solve.

I have no solution but a workaround for the problem.
You need to roll back the version of the extensions for now. With the following versions I could work around the problem:
Remote Development == 0.19.0
Remote SSH == 0.49.0
Here it is described how to roll back the versions: vs code - rollback extension/install specific extension version

I got the same issue but fixed it just after:
Removing the "known_hosts" file from SSH folder located in C:\Users<username>

Related

VSCode v1.43 remote ssh cannot connect. v1.42 works

I am connecting to a CENTOS 7.4 machine from my MAC using remote ssh extension. Everything was working fine in v1.42. I updated to v1.43 yesterday and now VSCode cannot connect. I get following error and it 'hangs' till I select close remote connection. I switched back to v1.42 and it works. Anyone else seen this?
[11:48:35.614] stderr> Authenticated to 172.18.116.204 ([172.18.116.204]:22).
[11:48:35.704] > Warning: no access to tty (Bad file descriptor).
[11:48:35.707] > Thus no job control in this shell.
[11:48:36.308] stderr> stty:
[11:48:36.308] stderr> standard input: Inappropriate ioctl for device
[11:48:36.309] stderr>
[11:48:38.151] stderr> stty:
[11:48:38.152] stderr> standard input: Inappropriate ioctl for device
[11:48:38.152] > ready: 552eb5fb743e
[11:48:38.180] > Linux 3.10.0-693.el7.x86_64 #1 SMP Tue Aug 22 21:09:27 UTC 2017
[11:48:38.180] Platform: linux
[11:48:38.246] stderr> bash: line 1: syntax error near unexpected token `then'
[11:48:38.246] stderr> bash: line 1: `then'
[11:48:38.247] stderr> function: Command not found.
[11:48:38.247] > 552eb5fb743e: running
[11:48:38.248] stderr> COMMIT_ID=78a4c91400152c0f27ba4d363eb56d2835f9903a: Command not found.
[11:48:38.248] stderr> EXTENSIONS=: Command not found.
[11:48:38.249] stderr> TELEMETRY=: Command not found.
[11:48:38.263] stderr> export: Permission denied.
[11:48:38.282] stderr> ALLOW_CLIENT_DOWNLOAD=1: Command not found.
[11:48:38.282] stderr> VSCODE_AGENT_FOLDER: Undefined variable.
[11:48:38.283] stderr> _lock: Command not found.
This is an open issue in VSCode Remote-SSH version 0.50.0. See Issue #2527.
The way I resolved it was to downgrade to version 0.49.0.
In VSCode, Ctrl+Shift+X to open extensions
Click the Manage icon next to the Remote - SSH extension
Click Install Another Version... from the options
Select the version to install (0.49.0)
I also recommend disabling the Extensions Auto Update in settings so this type of thing doesn't happen in the future with this or any other extensions.
I think that is NOT a issue of VSCode(v1.42 or 1.43). You can try to downgrade Remote-SSH extension to version 0.49.
I solved it by Cleaning up the VS Code Server on the remote. No uninstalling, no downgrading...
Simply:
Close VS Code
SSH into the remote using any other way, and run the commands from the link:
kill -9 `ps ax | grep "remoteExtensionHostAgent.js" | grep -v grep | awk '{print $1}'`
kill -9 `ps ax | grep "watcherService" | grep -v grep | awk '{print $1}'`
rm -rf ~/.vscode-server # Or ~/.vscode-server-insiders
Open VS Code again (it will re-install the remote server).
EDIT:
Running VS Code v1.43, Remote-SSH extension v0.50, on Windown 10.
Remote machine is CentOS 7

why ssh connection timed out in vscode?

I installed git instead of openssl to use Remote-SSH in VSCode.However,after I completed the config document and tried to connect to the remote host.I failed. The error info is showed in the below pic.error info
error info:
[11:27:12.631] remote-ssh#0.48.0
[11:27:12.632] win32 x64
[11:27:12.656] SSH Resolver called for "ssh-remote+23321", attempt 1
[11:27:12.659] SSH Resolver called for host: 23321
[11:27:12.659] Setting up SSH remote "23321"
[11:27:12.790] Using commit id "26076a4de974ead31f97692a0d32f90d735645c0" and quality "stable" for server
[11:27:12.798] Testing ssh with ssh -V
[11:27:13.099] ssh exited with code: 0
[11:27:13.100] Got stderr from ssh: OpenSSH_8.1p1, OpenSSL 1.1.1d 10 Sep 2019
[11:27:13.128] Running script with connection command: ssh -T -D 49485 23321 bash
[11:27:13.132] Install and start server if needed
[11:27:13.151] Terminal shell path: C:\Windows\System32\cmd.exe
[11:27:30.151] Resolver error: Connecting with SSH timed out
[11:27:30.178] ------
I had the same problem but the above solutions didn't work with my setup,
but the following setting did work:
"remote.SSH.useLocalServer": false
I got this solution from github reported issues and fix
In my case, the problem was caused by a too long authentication process on the server-side.
Solved it by extending the Connect Timeout from 15 to 30 seconds.
Instructions:
open your vscode Command Palette (via keyboard shortcut or from the
View menu).
search for the Remote-SSH: Settings.
scroll till you find the Connect Timeout.
change it to a longer duration than 15 secs.
key F1
Remote-SSH: Settings
Connect Timeout: from 15 seconds to 60 seconds solve my connection issue
You can try the following approaches:
ssh to your remote server. Then run the following commands to clean data folder and bin folder under .vscode-server folder on the server:
cd ~/.vscode-server
rm data/* -rf
rm bin/* -rf
If step 1 does not work, ssh to your remote server and delete the entire .vscode-server folder with the following command:
rm -rf ~/.vscode-server
Please note that this will also remove the extensions that you installed on the server.
Downgrade the version of the remote-SSH extension in vscode. Look up the extension in the vscode interface, right click on that, and you will find the option "Install Another Version ...". Install the previous version of the current one. If it does not work keep downgrading the version.
I had the same problem before, I solved this by deleting "terminal.integrated.inheritEnv": false inside ~/.config/Code/User/setting.json
I found the solution here in this thread from user oreilm49:
https://github.com/microsoft/vscode-remote-release/issues/1137
in vscode settings :
search conpty and uncheck it
I had same issue, my problem was solved after changing settings in the json file:
I removed "terminal.integrated.inheritEnv": false inside ~/.config/Code/User/setting.json
I added "remote.SSH.useLocalServer": true inside ~/.config/Code/User/setting.json
It worked for me after so many different trials
This might be a very foolish solution but it actually works for me, so I will write it down in case any other people get into the same problem.
I made modifications to the config file for SSH, then all the trials for connection ran into the error of 'Connecting SSH timed out'. I tried many possible solutions but none of them solved my problem.
Then I just closed the VScode and restarted it. Then everything works.
I had a case of this. I my client (local computer) is a Mac, and I was connecting to Linux host. I just went to the setting "Remote Platform" under Remote.SSH settings, and explicitly told it that I am connecting to a Linux remote. After this, it started to work.
I had this issue because of version missmatch of client and server. After updating both to the same version, it worked for me.
The issue with me was timeout at first. I tried increasing the timeout in settings but then later found the issue was with "tar".
The vscode-server.tar.gz (probably a little change in the file name) was not able to install due to tar not being present in my host.
So I installed tar in the host as "yum install tar"
And then tried reconnecting to the server and it worked

VSCode Remote-SSH Cannot Connect

I'm trying to use the Remote-SSH extension to edit files on a Linux server from my Windows 10 development machine. Normally, I log into the server using VNC and edit files locally OR I use WinSCP to pull the files to my development machine and copy them back over when done. The Remote-SSH extension seems to be the answer to this inefficiency.
I can SSH just fine using Putty or using Git Bash, but Remote-SSH fails to connect. There's some hints in the error message, but I'm not sure how to interpret them.
Here is my SSH config file (redacted) and the error I receive (redacted):
Config:
Host xxx.yy.gov
HostName xxx.yy.gov
User myusername
Error Message:
[08:44:36.981] remote-ssh#0.47.2
[08:44:36.981] win32 x64
[08:44:36.983] SSH Resolver called for "ssh-remote+xxx.yy.gov", attempt 1
[08:44:36.983] SSH Resolver called for host: xxx.yy.gov
[08:44:36.983] Setting up SSH remote "xxx.yy.gov"
[08:44:37.030] Using commit id "[some-string-of-numbers]" and quality "stable" for server
[08:44:37.033] Testing ssh with ssh -V
[08:44:37.101] ssh exited with code: 0
[08:44:37.101] Got stderr from ssh: OpenSSH_for_Windows_7.6p1, LibreSSL 2.6.4
[08:44:37.105] Running script with connection command: ssh -T -D 52772 xxx.yy.gov bash
[08:44:37.107] Install and start server if needed
[08:44:37.111] Terminal shell path: C:\WINDOWS\System32\cmd.exe
[08:44:37.264] >
[08:44:37.264] Got some output, clearing connection timeout
[08:44:37.611] > myusername#xxx.yy.gov's password:
[08:44:37.612] Showing password prompt
[08:44:44.709] Got password response
[08:44:44.709] "install" wrote data to terminal: "**************"
[08:44:44.730] >
>
[08:44:45.102] > bash: bash: command not found
>
[08:44:45.476] "install" terminal command done
[08:44:45.476] Install terminal quit with output: bash: bash: command not found
[08:44:45.476] Received install output: bash: bash: command not found
[08:44:45.477] Stopped parsing output early. Remaining text: bash: bash: command not found
[08:44:45.477] Failed to parse remote port from server output
[08:44:45.477] Resolver error:
[08:44:45.480] TELEMETRY: {"eventName":"resolver","properties":{"outcome":"failure","reason":"UnparsableOutput",
"askedPw":"1","askedPassphrase":"0","asked2fa":"0","askedHostKey":"0","gotUnrecognizedPrompt":"0",
"remoteInConfigFile":"1"},"measures":{"resolveAttempts":1,"retries":1}}
[08:44:45.482] ------
VSCode Remote-SSH error
There are there are three ways you can try. I know the problem is annoying.
Check your vscode is local window or remote window. Then, check
remote-ssh setting. (Make sure Local Server Download is auto && Use
local Server is marked.).
Remote SSH:Path . you can switch to local ssh or git/ssh
Try to update or revert remote-ssh.(Version 0.50 can connect to server host stably, I found. This one is very useful.
Maybe you just select 'Linux' instead of 'Windows' though you are using Windows when you got the option to select Linux, Windows or Mac.
Since you are connecting to a server and not your own computer, the type of server you are connecting to is most likely Linux.

Using "Remote SSH" in VSCode on a target machine that only allows inbound SSH connections

Is there a way to use the VSCode Remote SSH extension to interact with a remote host that does not allow outbound internet connections?
Is it possible to download the vscode-server files from another system and copy to host?
I read this but I can't connect the server to internet.
When you connect to a host it executes a bash script that wgets or curls a tarball and extracts it in a directory in your home directory. Here's an offline workaround.
Attempt to connect, let it fail
On server, get the commit id
$ ls ~/.vscode-server/bin
553cfb2c2205db5f15f3ee8395bbd5cf066d357d
Download tarball replacing $COMMIT_ID with the the commit number from the previous step
For Stable Version
https://update.code.visualstudio.com/commit:$COMMIT_ID/server-linux-x64/stable
For Insider Version
https://update.code.visualstudio.com/commit:$COMMIT_ID/server-linux-x64/insider
Move tarball to ~/.vscode-server/bin/$COMMIT_ID/vscode-server-linux-x64.tar.gz
Extract tarball in this directory
$ cd ~/.vscode-server/bin/$COMMIT_ID
$ tar -xvzf vscode-server-linux-x64.tar.gz --strip-components 1
Connect again
You'll still need to install any extensions manually. There's a download button next to all the extensions in the marketplace. Once you have the .vsix file you can install them through the GUI with the Install from VSIX option in the extensions manager.
This is kind of a pain and hopefully they improve this process, but if you have a network-based home directory, you only have to do this once.
open vscode -> about
Version: 1.46.1
Commit: cd9ea6488829f560dc949a8b2fb789f3cdc05f5d
Date: 2020-06-17T21:17:14.222Z
Electron: 7.3.1
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Darwin x64 17.7.0
$COMMIT_ID = cd9ea6488829f560dc949a8b2fb789f3cdc05f5d
A new feature is being added to support offline install
However, you can now solve this issue by a new user setting in the Remote - SSH extension. If you enable the setting remote.SSH.allowLocalServerDownload, the extension will install the VS Code Server on the client first and then copy it over to the server via SCP.
Note: This is currently an experimental feature but will be turned on by default in the next release
https://code.visualstudio.com/blogs/2019/10/03/remote-ssh-tips-and-tricks
A a work around I have done the following:
Desktop ~/.ssh/config
...
Host *
RemoteForward 54321
...
Remote: ~/bin/wget in which ~/bin is added to PATH via .bashrc
#!/bin/bash
export LD_LIBRARY_PATH=$HOME/opt/lib/tsocks/
export TSOCKS_CONF_FILE=$HOME/opt/tsocks/tsocks.conf
$HOME/bin/tsocks /usr/bin/wget $#
Remote: ~/opt/tsocks/tsocks.conf
server = 127.0.0.1
server_port = 54321
server_type = 5
note tsocks binary has been scp-ed to ~/bin/tsocks and ~/opt/tsocks/ has been created with libtsocks.so which is normally stored in /usr/lib64/libtsocks.so
This is a work around that allows me to have wget functionality with out messing with anything outside my profile to get it to work (eg: no root required ... even though I have it).
Current Version of VS Code: 1.48.2
I just kill the wget process on the server end, and let the client download the archive and transfer it to the server end. That's quite easy as below.
make sure that you set in settings.json
"remote.SSH.allowLocalServerDownload": true,
execute the shell scrpits below.
# to find the <pid>
ps aux | grep wget | grep vscode-server
# kill the process
kill -9 <pid>
# then wait for the client downloading and transferring
# optional: If you want to know the progress, just
cd ~/.vscode-server/bin/<commit-id>/
watch -n 1 -d ls -rthl

cannot spawn C:\ProgramFiles(x86)\Git\cmd\: No such file or directory.

I have a problem when I'm trying to clone with git on cygwin. My GIT_SSH is
"C:\ProgramFiles(x86)\Git\bin\".
When I try to clone, here is the result:
$ git clone ssh://*****/home/local/git/prestashop myDirectory
Cloning into 'myDirectory'...
error: cannot spawn C:\ProgramFiles(x86)\Git\cmd\: No such file or directory
fatal: unable to fork
I've seen many question related to that problem but I can't find answers to solve this problem. All ideas welcome ! Thanks !
Following Git with SSH on Windows, you see that GIT_SSH should reference the ssh executable, not just its path:
(old msysgit)
set GIT_SSH=C:\Program Files (x86)\Git\bin\ssh.exe
(new 2015 git for Windows)
set GIT_SSH=C:\Program Files\Git\usr\bin\ssh.exe
In my case, since I was using Git Extensions (3.3.1), I had adjust my SSH Client path.
Todo so, I went to Menu Tools > Settings > Git Extensions (category on left side) > SSH and adjusted my SSH Client path to C:\Program Files\git\usr\bin\SSH.EXE
Update 1
Facing this issue once again, after switching to Putty, because Pageant allows me to set my private once a day without exposing outside, where I've forgot set Putty as my ssh client, by going to Tools > Settings > Git Extensions (category on left side) > SSH > And setting Putty as my ssh client