Remote SSh Connection with visual studio code (VSC)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Remote SSh Connection with visual studio code (VSC)

L1 Bithead

Hi

 

As you may be aware, the Visual Studio Code (VSC) editor comes with the remote connection functionality via ssh and thus it is possible to edit files remotely on linux servers.

 

The basic configuration is very simple and you only need to configure the host address and username to establish the connection.

 

It turns out that in my company where CyberArk is being implemented, the accounts that users access are managed by CyberArk and so it would be very convenient for developers to continue using VSC to edit their scripts without needing to be constantly using winscp to download their scripts for editing and re-uploading again after each code change.

 

I tested using the syntax connection via ssh proxy (PSMP) in the configuration of the VSC connection string but when I try to connect I always end up getting the same errors.

 

The configuration I have to connect via PSMP is as follows:

 

Host labclient1_pam

 HostName psmp_address

 User Administrator @ target_account @ target_address

 

When I try to connect and I'm asked for the password, put the login password on CyberArk, in this case the administrator account

 

The following appears in the VSC logs:

 

[17: 59: 58.678] Log Level: 2

[17: 59: 58.689] [email protected]

[17: 59: 58.689] win32 x64

[17: 59: 58.692] SSH Resolver called for "ssh-remote + labclient1_pam", attempt 1

[17: 59: 58.692] SSH Resolver called for host: labclient1_pam

[17: 59: 58.692] Setting up SSH remote "labclient1_pam"

[17: 59: 58.791] Using commit id "d5e9aa0227e057a60c82568bf31c04730dc15dcd" and quality "stable" for server

[17: 59: 58.792] Install and start server if needed

[18: 00: 00.186] Checking ssh with "ssh -V"

[18: 00: 01.015]> OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5

[18: 00: 01.019] Running script with connection command: ssh -T -D 58651 labclient1_pam bash

[18: 00: 01.089] Terminal shell path: C: \ WINDOWS \ System32 \ cmd.exe

[18: 00: 01.779]>

[18: 00: 01.779] Got some output, clearing connection timeout

[18: 00: 02.422]> cybr_user @ target_account @ target_address @ psmp_address's password:

[18: 00: 02.422] Showing password prompt

[18: 00: 08.132] Got password response

[18: 00: 08.133] "install" wrote data to terminal: "**********"

[18: 00: 08.182]>

>

[18: 00: 09.524]>

> This session is being recorded

>

[18: 00: 15.602]> 617c3c39a8a6: running

>

[18: 00: 15.814]> bash: line 193: unexpected EOF while looking for matching `" '

> bash: line 194: syntax error: unexpected end of file

>

[18: 00: 16.125] "install" terminal command done

[18: 00: 16.125] Install terminal quit with output: bash: line 194: syntax error: unexpected end of file

[18: 00: 16.125] Received install output: bash: line 194: syntax error: unexpected end of file

[18: 00: 16.126] Stopped parsing output early. Remaining text: bash: line 194: syntax error: unexpected end of file

[18: 00: 16.126] Failed to parse remote port from server output

[18: 00: 16.126] Resolve error:

[18: 00: 16.132] ------

 

 

on the PSMP side the logs are as follows:

 

 

[07/14/2020 | 18:26:53] | :: | PSPSD011I Finished InitPSMPsshd, starting actual user session

[07/14/2020 | 18:26:53] | :: | PSPSD064I Session type: [SSH Command without terminal]

[07/14/2020 | 18:26:53] | :: | PSPSD039I Default delimiter for syntax parsing: [@]

[07/14/2020 | 18:26:53] | :: | PSPSD039I Default delimiter for target address and port parsing: [#]

[07/14/2020 | 18:26:53] | :: | PSPSD043I Getting next connection parameter from the container (Extra information: mandatory = [1], par

ameter name = [Vault user])

[07/14/2020 | 18:26:53] | :: | PSPSD043I Getting next connection parameter from the container (Extra information: mandatory = [1], par

ameter name = [Target user])

[07/14/2020 | 18:26:53] | :: | PSPSD043I Getting next connection parameter from the container (Extra information: mandatory = [1], par

ameter name = [Target machine address])

[07/14/2020 | 18:26:53] | :: | Cryptolib is starting ...

[07/14/2020 | 18:26:53] | :: | Cryptolib was started successfully.

[07/14/2020 | 18:26:53] | :: | PSPSD071I Generating request to server.

[07/14/2020 | 18:26:53] | :: | PSPOC017I Connecting to server on socket [/var/opt/CARKpsmp/temp/.sockets/PSMPSRV/password]

[07/14/2020 | 18:26:53] | :: | PSPOC018I Client was successfully connected to server

[07/14/2020 | 18:26:53] | :: | PSPOC029I Sending Request to server

[07/14/2020 | 18:26:53] | :: | 507I Write message header: <? Xml version = "1.0" encoding = "UTF-8" standalone = "no"?> <Message> <Header>

 <ProtocolVersion> 700 </ProtocolVersion> <ProtocolInfo> 3 </ProtocolInfo> </Header> <Elements> **** </Elements> </Message>

[07/14/2020 | 18:26:53] | :: | PSPSD032I Waiting for PSM For SSH session response (Extra information: phase 1)

[07/14/2020 | 18:26:54] | :: | 505I Load message header: <? Xml version = "1.0" encoding = "UTF-8" standalone = "no"?> <Message> <Header>

<ProtocolVersion> 700 </ProtocolVersion> <ProtocolInfo> 3 </ProtocolInfo> </Header> <Elements> **** </Elements> </Message>

[1

 

Has anyone had this problem? Is this supported by Cyberark?

10 REPLIES 10

L3 Networker

Hi

 

We are experiencing exactly the same issue.

The Remote-SSH Extension in VSCode tries to execute an install script via SSH bash and that is being truncated through the PSMP SSH Proxy so that the bash execution fails at line 193/194. The script that is being executed is far larger: around ~12KB and ~470 lines.

 

PSMP is used with InstallSSHD = Yes

 

Github issue on this:

https://github.com/microsoft/vscode-remote-release/issues/2736

 

Does anyone know about bash remote execution limitations over PSMP and if its possible to raise that? Or any issues with the SSHD from CyberArk?

 

I could also imagine some issues DevOps tools/Ansible via PSMP

L7 Applicator

Not sure if that applies here, but CyberArk has some documentation about specific settings for automation tools, where the PSMP doesn't interfere (as much) with the SSH connection establishment: https://docs.cyberark.com/Product-Doc/OnlineHelp/PAS/Latest/en/Content/PASIMP/Configure%20PSMP%20to%...

L3 Networker

Hi Bernhard

 

Yes I tested these settings as well but remote bash commands are still truncated.

Those parameters enable a faster connection build up of many connections within a short time period - but will not change any limitations.

That's why I image also some issues that could interfere with DevOps tools via PSMP as well if they run larger bash commands over ssh.

 

L1 Bithead

I also tried to use the ProxyCommand option in VS Code

 

Host jump_box HostName <jump box address> User <PAM Account>   Host labclient1_pam HostName <target_address> User <target_account> ProxyCommand ssh -q -W %h:%p jump_box

 

 

but now I get this error:

> CreateProcessW failed error: 2

> posix_spawn: No such file or directory

 

L1 Bithead

I solved this problem using the plugin: https://marketplace.visualstudio.com/items?itemName=Kelvin.vscode-sshfs

L0 Member

Hi Luis,

 

can you expand how did you configure it?

 

i am getting this error. even though sftp through WinSCP works fine

 

[ERROR] Error while connecting to SSH FS test1: Error: Received exit code 255 while establishing SFTP session JSON: {"code":255} Error: Received exit code 255 while establishing SFTP session

 

As a follow up on this a few of us are also having this issue with connecting VS Code to CyberArk managed servers. We are testing a work around for this issue of VS Code passing an installation script as a test string to the server and getting the EOF error. We are now using the SSH-FS plugin for VS Code.

 

Add the following setting to settings.json file:

 

{

"window.zoomLevel": 2,

"sshfs.configs": [

{

"name": "<some arbitrary name>",

"host": "<cyberark jump host>",

"username": "userid@userid#[email protected]",

}

]

}

 

Also, modify your local config file (~/.ssh/config) so that it doesn't write to the known_hosts file:

 

Host carkpsmp*

        StrictHostKeyChecking no

        UserKnownHostsFile=/dev/null

 

 

 

L0 Member

Hi, is there a solution found for this issue, I am facing the same. Thank you

@1_luis.filipe

Can you please help me understand how you configured SSH FS for use through the CyberArk PSMP ?

L3 Networker

has anybody got solution on this? any official documented suggesstion?

  • 5601 Views
  • 10 replies
  • 0 Likes
Like what you see?

Show your appreciation!

Click Like if a post is helpful to you or if you just want to show your support.

Click Accept as Solution to acknowledge that the answer to your question has been provided.

The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!

These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!

The LIVEcommunity thanks you for your participation!