Cannot SSH to Remote on VSCode - linux

My SSH setup was working fine for the past 3-4 months, until a few days back when it decided to stop working on vscode. I can still ssh to remote via powershell without any issues.
The Issue: Once I enter my passphrase and 2fa authentication, something runs in the background (The output from Remote-SSH stream is dumped below). After which, it asks for my passphrase again, 2fa and so on, and this keeps repeating on a loop.
Methods Tried:
First I tried "Remote: Kill VScode on Remote Host" - The first time I tried this, it worked, I could SSH. But after that session ended, I faced the same issue again. But this time when I executed "Remote: Kill VScode on Remote Host" again it didn't work like the last time.
Manually deleted the .vscode on the remote host - It didn't work
Uninstalled and reinstalled VScode, similar to method 1, It worked for the first SSH session, but failed with some issues for consequent sessions.
Toggled remote.SSH.useFlock setting - didn't work
Toggled remote.SSH.useLocalServer - didn't work
How can I fix this?(preferred)
Is there any alternative to using Remote - SSH extension on vscode if nothing works?
Any other alternative as good as vscode without the requirement of downloading the remote file locally?
[12:09:32.264] > Passcode or option (1-6): 1
[12:09:32.551] >
>
[12:09:37.009] > aae6d4629bbb: running
[12:09:37.050] >
> Acquiring lock on /home1/<user>/.vscode-server/bin/da47g5wf6ef856477bf6f4fb29ba1b7af717770d/vscode-remote-lock.<user>.da47g5wf6ef856477bf6f4fb29ba1b
> 7af717770d
> Installation already in progress...
> If you continue to see this message, you can try toggling the remote.SSH.useFlock setting
> aae6d4629bbb: start
> exitCode==24==
> listeningOn====
> osReleaseId==centos==
> arch==x86_64==
> tmpDir==/run/user/601613==
> platform==linux==
> unpackResult====
> didLocalDownload==0==
> downloadTime====
> installTime====
> extInstallTime====
> serverStartTime====
> aae6d4629bbb: end
>
[12:09:37.050] Received install output:
exitCode==24==
listeningOn====
osReleaseId==centos==
arch==x86_64==
tmpDir==/run/user/601613==
platform==linux==
unpackResult====
didLocalDownload==0==
downloadTime====
installTime====
extInstallTime====
serverStartTime====
[12:09:37.051] Server installation process already in progress - waiting and retrying
[12:09:37.406] "install" terminal command done
[12:09:37.406] Install terminal quit with output:
[12:09:38.055] Running script with connection command: ssh -T -D 55819 "<host>" bash
[12:09:38.056] Terminal shell path: C:\WINDOWS\System32\cmd.exe
[12:09:38.289] >
[12:09:38.289] Got some output, clearing connection timeout
[12:09:38.752] > two-factor login for <user>
>
> Enter a passcode or select one of the following options:
> Passcode or option (1-6):
This keeps repeating without end

Related

Remote SSH: "/bin/bash: No such file or directory" when attempting to connect to a remote server

Software
Version
Client Machine OS
Windows 10 x64
Target Machine OS
Ubuntu 20.04.4 LTS (GNU/Linux 5.4.0-100-generic x86_64)
VS Code
1.65.0
VS Code Remote - SSH (Stable)
0.76.1
I'm trying to use the Remote SSH extension in VS Code to edit files on a remote server. In C:\Users\me\.ssh\config I have the following host configured:
Host druid
HostName mydomain.com
Port 22
User myuser
IdentityFile "K:\PathToKey\id_ed25519"
When trying to connect to this target host, I'm prompted for its OS type, then sometimes the key's password, then it fails. I get the following output:
[21:35:06.080] Log Level: 2
[21:35:06.082] remote-ssh#0.76.1
[21:35:06.082] win32 x64
[21:35:06.091] SSH Resolver called for "ssh-remote+druid", attempt 1
[21:35:06.092] "remote.SSH.useLocalServer": false
[21:35:06.092] "remote.SSH.showLoginTerminal": false
[21:35:06.092] "remote.SSH.remotePlatform": {}
[21:35:06.095] "remote.SSH.path": undefined
[21:35:06.095] "remote.SSH.configFile": undefined
[21:35:06.095] "remote.SSH.useFlock": true
[21:35:06.095] "remote.SSH.lockfilesInTmp": false
[21:35:06.096] "remote.SSH.localServerDownload": auto
[21:35:06.096] "remote.SSH.remoteServerListenOnSocket": false
[21:35:06.096] "remote.SSH.showLoginTerminal": false
[21:35:06.096] "remote.SSH.defaultExtensions": []
[21:35:06.096] "remote.SSH.loglevel": 2
[21:35:06.096] "remote.SSH.enableDynamicForwarding": true
[21:35:06.097] "remote.SSH.enableRemoteCommand": false
[21:35:06.097] "remote.SSH.serverPickPortsFromRange": {}
[21:35:06.097] "remote.SSH.serverInstallPath": {}
[21:35:06.138] SSH Resolver called for host: druid
[21:35:06.138] Setting up SSH remote "druid"
[21:35:06.151] Using commit id "b52...d43" and quality "stable" for server
[21:35:06.155] Install and start server if needed
[21:35:07.663] Checking ssh with "ssh -V"
[21:35:07.709] > OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2
[21:35:07.714] Running script with connection command: ssh -T -D 65124 druid bash
[21:35:07.718] Terminal shell path: C:\Windows\System32\cmd.exe
[21:35:07.955] > ]0;C:\Windows\System32\cmd.exe
[21:35:07.956] Got some output, clearing connection timeout
[21:35:09.262] > /bin/bash: No such file or directory
[21:35:10.541] "install" terminal command done
[21:35:10.542] Install terminal quit with output: ]0;C:\Windows\System32\cmd.exe/bin/bash: No such file or directory
[21:35:10.542] Received install output: ]0;C:\Windows\System32\cmd.exe/bin/bash: No such file or directory
[21:35:10.543] Failed to parse remote port from server output
[21:35:10.544] Resolver error: Error:
at Function.Create (c:\Users\me\.vscode\extensions\ms-vscode-remote.remote-ssh-0.76.1\out\extension.js:1:586041)
at Object.t.handleInstallOutput (c:\Users\me\.vscode\extensions\ms-vscode-remote.remote-ssh-0.76.1\out\extension.js:1:584693)
at Object.t.tryInstall (c:\Users\me\.vscode\extensions\ms-vscode-remote.remote-ssh-0.76.1\out\extension.js:1:681846)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async c:\Users\me\.vscode\extensions\ms-vscode-remote.remote-ssh-0.76.1\out\extension.js:1:644486
at async Object.t.withShowDetailsEvent (c:\Users\me\.vscode\extensions\ms-vscode-remote.remote-ssh-0.76.1\out\extension.js:1:647831)
at async Object.t.resolve (c:\Users\me\.vscode\extensions\ms-vscode-remote.remote-ssh-0.76.1\out\extension.js:1:645565)
at async c:\Users\me\.vscode\extensions\ms-vscode-remote.remote-ssh-0.76.1\out\extension.js:1:722872
[21:35:10.550] ------
I believe these lines in particular point to the root of the problem:
[21:35:07.714] Running script with connection command: ssh -T -D 65124 druid bash
[21:35:07.718] Terminal shell path: C:\Windows\System32\cmd.exe
[21:35:07.955] > ]0;C:\Windows\System32\cmd.exe
[21:35:07.956] Got some output, clearing connection timeout
[21:35:09.262] > /bin/bash: No such file or directory
[21:35:10.541] "install" terminal command done
[21:35:10.542] Install terminal quit with output: ]0;C:\Windows\System32\cmd.exe/bin/bash: No such file or directory
[21:35:10.542] Received install output: ]0;C:\Windows\System32\cmd.exe/bin/bash: No such file or directory
It looks like the code or script of the plugin is trying to run /bin/bash (on the client machine?), but it's using cmd.exe to do so unsuccessfully. I've tried every workaround I could find, but none have worked so far. For reference, I've tried:
Switching remote.SSH.useLocalServer between true and false in
C:\Users\me\AppData\Roaming\Code\User\settings.json
Pointing a "PATH" value to C:\Program Files\Git\usr\bin, C:\Program Files\Git\bin, or nothing at all ("") in the terminal.integrated.shell.windows and terminal.integrated.shell.linux settings in my VS Code settings.json, hoping it would pick up bash.exe, or at least override something incorrectly set elsewhere
Setting the default terminal profile to either Git Bash or Ubuntu (WSL)
Specifying an absolute path to both the ssh executable and the config file in Remote.SSH settings
Running ssh -T -D 65124 druid bash in a PowerShell terminal to compare with Remote SSH output (gives one line: /bin/bash: No such file or directory)
Running ldd /bin/bash on both the target machine and in an Ubuntu WSL terminal to compare output (identical)
Checking home directories for a .vscode-server directory to delete and regenerate, as suggested here
Running Remote-SSH: Kill VS Code Server on Host... in the VS Code Command Palette on client machine, which may or may not do the same thing as the solution above
Uninstalling and reinstalling the Remote SSH VS Code extension
I was hoping that I'd figure it out in the process of writing this all down and retracing my steps, but I'm still at a loss. Any advice would be much appreciated!

MobaXterm gets stuck on "Please wait while opening file..." dialog

I am using MobaXterm v20.6 build 4532 to connect to a Linux machine over SSH. I am trying to open a file in the Scp panel on the left by double-clicking on it, and this brings up a dialog box saying "Please wait while opening file...", and it gets stuck here forever.
Interestingly enough, this works on some servers but not others. Is there some way to debug this? Is there a log file which shows the scp command that MobaXterm is trying to run?
I figured out the problem. I was able to enable logging by running "MobaXterm.exe -log". This left a log in C:\Users\jdoe\Documents\MobaXterm\MobaXterm.log. This was printed when I tried to open a file:
[11:31.39.305] (SSH-Browser) Starting MobaSCP(2, OpenFile, /local/jdoe/.bashrc, C:\Users\JDOE\DOCUME~1\MobaXterm\slash\RemoteFiles\526608_2_0\.bashrc)
[11:31.39.307] BEGIN ShellExecuteA(C:\Users\JDOE\DOCUME~1\MobaXterm\slash\bin\MobaSCPOpenFile.exe, -v -batch -scp -load "TERM5266082" mobauser#mobaserver:"/local/jdoe/.bashrc" "C:\Users\JDOE\DOCUME~1\MobaXterm\slash\RemoteFiles\526608_2_0\.bashrc")
[11:31.39.308] ShellExecuteA: ShellExecuteEx succeeded.
[11:31.39.308] END ShellExecuteA(C:\Users\JDOE\DOCUME~1\MobaXterm\slash\bin\MobaSCPOpenFile.exe, -v -batch -scp -load "TERM5266082" mobauser#mobaserver:"/local/jdoe/.bashrc" "C:\Users\JDOE\DOCUME~1\MobaXterm\slash\RemoteFiles\526608_2_0\.bashrc")
[11:31.39.405] [MobaSCP2] Multiplex=0
[11:31.39.406] [MobaSCP2] HOSTNAME: 192.168.1.104
[11:31.39.406] [MobaSCP2] USERNAME: jdoe
[11:31.39.724] Received verification request for hostkey: ssh-ed25519#22:192.168.1.104
[11:31.39.724] Hostkey corresponds to the cached one
[11:31.39.748] WMNewTab2: Saving sshkey and NOT CONNECTING SSH-Browser...
[11:31.39.748] BEGIN SavePassword
[11:31.39.749] END SavePassword
[11:31.39.845] [MobaSCP2] Using SCP1
[11:31.39.845] [MobaSCP2] Connected to 192.168.1.104
[11:31.39.845] [MobaSCP2] Protocol error: Expected control record
Looks like the "Expected control record" error was being caused by my .bashrc printing output. Apparently this confuses SCP: https://documentation.help/PuTTY/faq-pscp-protocol.html
I was able to fix this by changing my .bashrc to not print anything.

What is a "Failed to create hard link: File exists" error?

I'm trying to do a SSH login from VSCode using the Remote SSH extension and I'm getting this error. It is working fine when I login from my GIT terminal.
The error stack:
[20:44:36.547] > \ln /root/.vscode-server/bin/a5d1cc28bb5da32ec67e86cc50f84c67cc690321/vscode-rem
> ote-lock.root.a5d1cc28bb5da32ec67e86cc50f84c67cc690321.target /root/.vscode-serv
> er/bin/a5d1cc28bb5da32ec67e86cc50f84c67cc690321/vscode-remote-lock.root.a5d1cc28
> bb5da32ec67e86cc50f84c67cc690321
>
[20:44:36.555] > ln: failed to create hard link ‘/root/.vscode-server/bin/a5d1cc28bb5da32ec67e86c
> c50f84c67cc690321/vscode-remote-lock.root.a5d1cc28bb5da32ec67e86cc50f84c67cc6903
> 21’: File exists
> Installation already in progress...
> e6e07fdafb38##24##
>
[20:44:36.555] Received install output: e6e07fdafb38##24##
[20:44:36.556] Server installation process already in progress - waiting and retrying
[20:44:36.827] "install" terminal command done
[20:44:36.827] Install terminal quit with output:
[20:44:37.557] Resolver error:
[20:44:37.560] ------
I had the same problem after updating VScode.
Not sure if this is the correct solution but it does work:
Login to your server via another ssh program like PuTTY, because your file is located in the root user home directory you'll need to login as root to do this.
Delete folder a5d1cc28bb5da32ec67e86c from /root/.vscode-server/bin/ directory.
Found the answer here:
https://github.com/microsoft/vscode-remote-release/issues/2507

error running run file in centOS - bad display

I have a task to install Oracle 11g on a centOS 8 using VM (i'm new to linux / oracle).
I downloaded the Oracle files and unzipped them, then I tried to ./runInstaller but I get an error and this is the full terminal with error:
login as: admin
admin#192.168.163.129's password:
Activate the web console with: systemctl enable --now cockpit.socket
Last login: Thu May 21 09:26:48 2020 from 192.168.163.1
[admin#oracledb ~]$ cd Downloads
[admin#oracledb Downloads]$ cd database
[admin#oracledb database]$ ls
doc linux.x64_11gR2_database_1of2 response runInstaller stage
install linux.x64_11gR2_database_2of2 rpm sshsetup welcome.html
[admin#oracledb database]$ ./runInstaller
Starting Oracle Universal Installer...
Checking Temp space: must be greater than 120 MB. Actual 2027 MB Passed
Checking swap space: must be greater than 150 MB. Actual 1759 MB Passed
Checking monitor: must be configured to display at least 256 colors
>>> Could not execute auto check for display colors using command /usr/bin/xdpyinfo. Check if the DISPLAY variable is set. Failed <<<<
Some requirement checks failed. You must fulfill these requirements before
continuing with the installation,
Continue? (y/n) [n] y
>>> Ignoring required pre-requisite failures. Continuing...
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2020-05-21_09-43-58AM. Please wait ...
DISPLAY not set. Please set the DISPLAY and try again.
Depending on the Unix Shell, you can use one of the following commands as examples to set the DISPLAY environment variable:
- For csh: % setenv DISPLAY 192.168.1.128:0.0
- For sh, ksh and bash: $ DISPLAY=192.168.1.128:0.0; export DISPLAY
Use the following command to see what shell is being used:
echo $SHELL
Use the following command to view the current DISPLAY environment variable setting:
echo $DISPLAY
- Make sure that client users are authorized to connect to the X Server.
To enable client users to access the X Server, open an xterm, dtterm or xconsole as the user that started the session and type the following command:
% xhost +
To test that the DISPLAY environment variable is set correctly, run a X11 based program that comes with the native operating system such as 'xclock':
% <full path to xclock.. see below>
If you are not able to run xclock successfully, please refer to your PC-X Server or OS vendor for further assistance.
Typical path for xclock: /usr/X11R6/bin/xclock
[admin#oracledb database]$
I am using putty and Xming but I still get this error.
Make sure your putty session is connecting with "x-11 port forwarding"
Be sure after you set this that you scroll back up to 'Session' and then 'save'

127 Build step > 'Execute shell script on remote host using ssh' marked build as > failure Finished: FAILURE

I am trying to use sh or ssh to connect to a linux box via jenkins (I am a noob admittedly). Even trying a ls command I am getting error - I did have this working before however - any help greatly appreciated.
Building in workspace /var/lib/jenkins/jobs/Demo/workspace executing
script:
USER="jenkins" sh '''#!/bin/bash
HOST=10.59.151.121
USER=devuser
PASSWORD=TGMCfpfS
ls
bye
EOF
'''
: No such file or directory [SSH] exit-status: 127 Build step
'Execute shell script on remote host using ssh' marked build as
failure Finished: FAILURE
For some reason I found that adding commands after the ''' allows them to be executed - even although the same warning appears, it works fine!

Resources