SchoofsKelvin / vscode-sshfs

Extension for Visual Studio Code: File system provider using SSH
GNU General Public License v3.0
543 stars 36 forks source link

Disconnects immediately when adding folder as a workspace -- yet connecting via terminal works fine. #359

Closed billdacat closed 1 year ago

billdacat commented 1 year ago

User can open VS Code and use the 'Open remote SSH terminal' option in SSH FS to connect. That works.

User tries to 'Add as Workspace folder'. Fails. Looked at the /var/log/messages and /var/log/secure, it's apparently successfully authenticating the user, then immediately disconnecting. I'd think the user didn't have a shell or something, but they can connect via the terminal in SSH FS and it's fine.

billdacat commented 1 year ago

Relevant log parts:

[INFO]    [createConnection(dcstats-etl,config)] Remote version: OpenSSH_7.7
[DEBUG]   [ssh2(dcstats-etl)] Outbound: Sending CHANNEL_OPEN (r:0, session)
[DEBUG]   [ssh2(dcstats-etl)] Inbound: GLOBAL_REQUEST ([hostkeys-00@openssh.com](mailto:hostkeys-00@openssh.com))
[DEBUG]   [ssh2(dcstats-etl)] Outbound: Sending GLOBAL_REQUEST ([hostkeys-prove-00@openssh.com](mailto:hostkeys-prove-00@openssh.com))
[DEBUG]   [ssh2(dcstats-etl)] Inbound: CHANNEL_OPEN_CONFIRMATION (r:0, s:0)
[DEBUG]   [ssh2(dcstats-etl)] Outbound: Sending CHANNEL_REQUEST (r:0, exec: echo :::SHELL:$SHELL:SHELL:::)
[DEBUG]   [ssh2(dcstats-etl)] Inbound: REQUEST_SUCCESS
[DEBUG]   [ssh2(dcstats-etl)] Inbound: CHANNEL_WINDOW_ADJUST (r:0, 2097152)
[DEBUG]   [ssh2(dcstats-etl)] Inbound: CHANNEL_SUCCESS (r:0)
[DEBUG]   [ssh2(dcstats-etl)] Inbound: CHANNEL_DATA (r:0, 28)
[DEBUG]   [ssh2(dcstats-etl)] Inbound: CHANNEL_EOF (r:0)
[DEBUG]   [ssh2(dcstats-etl)] Inbound: CHANNEL_REQUEST (r:0, exit-status: 0)
[DEBUG]   [ssh2(dcstats-etl)] Inbound: CHANNEL_CLOSE (r:0)
[DEBUG]   [ssh2(dcstats-etl)] Outbound: Sending CHANNEL_CLOSE (r:0)
[DEBUG]   [createConnection(dcstats-etl,config)] Detected known $SHELL '/bin/bash' (bash)
[DEBUG]   [ssh2(dcstats-etl)] Outbound: Sending CHANNEL_OPEN (r:1, session)
[DEBUG]   [ssh2(dcstats-etl)] Inbound: CHANNEL_OPEN_CONFIRMATION (r:1, s:0)
[DEBUG]   [ssh2(dcstats-etl)] Outbound: Sending CHANNEL_REQUEST (r:0, exec: echo "::`echo 26283`:echo_result:`echo ~`:`echo 26283`::")
[DEBUG]   [ssh2(dcstats-etl)] Inbound: CHANNEL_WINDOW_ADJUST (r:1, 2097152)
[DEBUG]   [ssh2(dcstats-etl)] Inbound: CHANNEL_SUCCESS (r:1)
[DEBUG]   [ssh2(dcstats-etl)] Inbound: CHANNEL_DATA (r:1, 52)
[DEBUG]   [ssh2(dcstats-etl)] Inbound: CHANNEL_EOF (r:1)
[DEBUG]   [ssh2(dcstats-etl)] Inbound: CHANNEL_REQUEST (r:1, exit-status: 0)
[DEBUG]   [ssh2(dcstats-etl)] Inbound: CHANNEL_CLOSE (r:1)
[DEBUG]   [ssh2(dcstats-etl)] Outbound: Sending CHANNEL_CLOSE (r:0)
[DEBUG]   [createConnection(dcstats-etl,config)] Home path: /home/hiraic@AD.SEC.GOV
[DEBUG]   [createConnection(dcstats-etl,config)] Environment: []
[INFO]    [getSFTP(dcstats-etl)] Creating SFTP session using standard sftp subsystem
[DEBUG]   [ssh2(dcstats-etl)] Outbound: Sending CHANNEL_OPEN (r:2, session)
[DEBUG]   [ssh2(dcstats-etl)] Inbound: CHANNEL_OPEN_CONFIRMATION (r:2, s:0)
[DEBUG]   [ssh2(dcstats-etl)] Outbound: Sending CHANNEL_REQUEST (r:0, subsystem: sftp)
[DEBUG]   [ssh2(dcstats-etl)] Inbound: CHANNEL_WINDOW_ADJUST (r:2, 2097152)
[DEBUG]   [ssh2(dcstats-etl)] Inbound: CHANNEL_SUCCESS (r:2)
[DEBUG]   [ssh2(dcstats-etl)] Outbound: Sending CHANNEL_DATA (r:0, 9)
[DEBUG]   [ssh2(dcstats-etl)] Inbound: CHANNEL_EOF (r:2)
[DEBUG]   [ssh2(dcstats-etl)] Inbound: CHANNEL_REQUEST (r:2, exit-status: 255)
[DEBUG]   [ssh2(dcstats-etl)] Inbound: CHANNEL_CLOSE (r:2)
[ERROR]   Error while connecting to SSH FS dcstats-etl:
Error: Received exit code 255 while establishing SFTP session
JSON: {"code":255}
Error: Received exit code 255 while establishing SFTP session
    at SFTP.a (c:\Users\hiraic\.vscode\extensions\kelvin.vscode-sshfs-1.25.0\dist\14f8.extension.js:1:105838)
    at SFTP.emit (events.js:315:20)
    at CHANNEL_REQUEST (c:\Users\hiraic\.vscode\extensions\kelvin.vscode-sshfs-1.25.0\dist\14f8.extension.js:1:93922)
    at 98 (c:\Users\hiraic\.vscode\extensions\kelvin.vscode-sshfs-1.25.0\dist\14f8.extension.js:1:247038)
    at e.exports.D (c:\Users\hiraic\.vscode\extensions\kelvin.vscode-sshfs-1.25.0\dist\14f8.extension.js:1:109909)
    at D.decrypt (c:\Users\hiraic\.vscode\extensions\kelvin.vscode-sshfs-1.25.0\dist\14f8.extension.js:1:201682)
    at e.exports.H [as _parse] (c:\Users\hiraic\.vscode\extensions\kelvin.vscode-sshfs-1.25.0\dist\14f8.extension.js:1:109433)
    at e.exports.parse (c:\Users\hiraic\.vscode\extensions\kelvin.vscode-sshfs-1.25.0\dist\14f8.extension.js:1:113236)
    at Socket.<anonymous> (c:\Users\hiraic\.vscode\extensions\kelvin.vscode-sshfs-1.25.0\dist\14f8.extension.js:1:95036)
    at Socket.emit (events.js:315:20)
Caused by toPromise:
    at I (c:\Users\hiraic\.vscode\extensions\kelvin.vscode-sshfs-1.25.0\dist\14f8.extension.js:1:62949)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at c:\Users\hiraic\.vscode\extensions\kelvin.vscode-sshfs-1.25.0\dist\extension.js:11:23642
Caused by catchingPromise:
    at i (c:\Users\hiraic\.vscode\extensions\kelvin.vscode-sshfs-1.25.0\dist\extension.js:11:6396)
    at m.createFileSystem (c:\Users\hiraic\.vscode\extensions\kelvin.vscode-sshfs-1.25.0\dist\extension.js:11:23282)
    at r.assertFs (c:\Users\hiraic\.vscode\extensions\kelvin.vscode-sshfs-1.25.0\dist\extension.js:11:11864)
    at r.stat (c:\Users\hiraic\.vscode\extensions\kelvin.vscode-sshfs-1.25.0\dist\extension.js:11:11971)
    at P.$stat (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:84:164584)
    at c._doInvokeHandler (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:88:12743)
    at c._invokeHandler (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:88:12435)
    at c._receiveRequest (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:88:11097)
    at c._receiveOneMessage (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:88:9900)
    at c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:88:8004
Logged at:
    at c:\Users\hiraic\.vscode\extensions\kelvin.vscode-sshfs-1.25.0\dist\extension.js:11:24945
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
[DEBUG]   [ssh2(dcstats-etl)] Outbound: Sending ping (GLOBAL_REQUEST: [keepalive@openssh.com](mailto:keepalive@openssh.com))
[DEBUG]   [ssh2(dcstats-etl)] Inbound: Received REQUEST_FAILURE
[DEBUG]   [ssh2(dcstats-etl)] Outbound: Sending ping (GLOBAL_REQUEST: [keepalive@openssh.com](mailto:keepalive@openssh.com))
[DEBUG]   [ssh2(dcstats-etl)] Inbound: Received REQUEST_FAILURE
[DEBUG]   [ssh2(dcstats-etl)] Outbound: Sending ping (GLOBAL_REQUEST: [keepalive@openssh.com](mailto:keepalive@openssh.com))
[DEBUG]   [ssh2(dcstats-etl)] Inbound: Received REQUEST_FAILURE
billdacat commented 1 year ago

Appears to have been some Cyberark issue, but still not understanding fully why it would allow a normal SSH terminal connection through VS/SSH-FS, and not adding a folder as a workspace.

worksofliam commented 1 year ago

I don't dev this extension, but it could possible be due to a change in the VS Code API when adding folders to the workspace.

SchoofsKelvin commented 1 year ago

Does this issue still occur?

While the sftp subsystem call failing with a status code 255 doesn't tell me much, the little what I can find about it mentions the user not having configured a proper terminal. Since you can still create a terminal, that shouldn't an issue (unless you changed SFTP Command or Terminal Command or similar).

Does SFTP work outside the extension? Perhaps running the subsystem (or /usr/lib/openssh/sftp-server which OpenSSH uses) got blocked by Cyberark.

billdacat commented 1 year ago

It was some sort of configuration issue on the CyberArk side they resolved. That's another team/division from where I'm at, so unfortunately I don't have a lot of insight into what they actually changed.

SFTP was working outside the extension, from a normal terminal prompt, yes.

SchoofsKelvin commented 1 year ago

Then I'll assume it's a security feature based on e.g. the SSH client's ident (SSH-2.0-ssh2js) or similar, hard to diagnose/fix at this point. I'll close the ticket since that team figured out what's causing it on their end.