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

Terminal doesn't interpret commands properly? #313

Closed MikeK184 closed 2 years ago

MikeK184 commented 2 years ago

Hi there,

I've been using this plugin recently and I'm overall pleased, but there is one issue that keeps bothering me. For some reason commands are not recognized as such in the remote as it would be with a 'native ssh' connection. Here is an example:

Connecting to sshopsmanager...

ubuntu@pkstest-ops-manager:~$ bosh vms
Expected non-empty Director URL

Exit code 1

After using exit to leave the remote VSCode comes up with the following image

However if i use ssh directly from the terminal and pass in the keyphrase it works:

ssh ubuntu@pkstest-ops-manager.m086 -i id_rsa_opstest
############## TKGI TEST##############
Enter passphrase for key 'id_rsa_opstest': 
Welcome to Ubuntu 16.04.7 LTS (GNU/Linux 4.15.0-159-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage
Last login: Mon Nov 22 10:31:02 UTC 2021 from 10.184.40.16 on pts/0
Last login: Mon Nov 22 10:41:10 2021 from 10.184.40.16

ubuntu@pkstest-ops-manager:~$ bosh vms
Using environment '172.30.72.3' as client 'ops_manager'

Task 1379004
Task 1379003
Task 1379002
Task 1379005
Task 1379004 done

...

The Logs are the following:

[INFO]    
Created output channel for vscode-sshfs
When posting your logs somewhere, keep the following in mind:
  - While the logging tries to censor your passwords/passphrases/..., double check!
    Maybe you also want to censor out e.g. the hostname/IP you're connecting to.
  - If you want to report an issue regarding authentication or something else that
    seems to be more of an issue with the actual SSH2 connection, it might be handy
    to reconnect with this added to your User Settings (settings.json) first:
      "sshfs.flags": [ "DEBUG_SSH2" ],
    This will (for new connections) also enable internal SSH2 logging.

[INFO]    Loading configurations...
[INFO]    Calculated config flags: {}
[DEBUG]     Added configuration sshopsmanager from [1]
[INFO]    Found 1 configurations
[INFO]    Extension activated, version 1.24.0, mode 1
[INFO]    Command received to open a terminal for FileSystemConfig(sshopsmanager)
[INFO]    [createConnection(sshopsmanager,config)] Creating a new connection for 'sshopsmanager'
[INFO]    Calculating actual config
[DEBUG]     Read private key from /home/rsmi077/.ssh/id_rsa_opstest
[DEBUG]     Final configuration:
{
    "name": "sshopsmanager",
    "host": "pkstest-ops-manager.m086",
    "username": "ubuntu",
    "privateKeyPath": "/home/rsmi077/.ssh/id_rsa_opstest",
    "passphrase": "<censored>",
    "root": "/home/ubuntu",
    "agentForward": false,
    "_location": 1,
    "_locations": [
        1
    ],
    "_calculated": {
        "name": "sshopsmanager",
        "host": "pkstest-ops-manager.m086",
        "username": "ubuntu",
        "privateKeyPath": "/home/rsmi077/.ssh/id_rsa_opstest",
        "passphrase": "<censored>",
        "root": "/home/ubuntu",
        "agentForward": false,
        "_location": 1,
        "_locations": [
            1
        ]
    },
    "port": 22,
    "privateKey": "Buffer(1876)"
}
[INFO]    [createSocket(sshopsmanager)] Creating socket
[DEBUG]   [createSocket(sshopsmanager)] Connecting to pkstest-ops-manager.m086:22
[INFO]    [createConnection(sshopsmanager,config)] Remote version: OpenSSH_7.2p2
[DEBUG]   [createConnection(sshopsmanager,config)] Detected known $SHELL '/bin/bash' (bash)
[DEBUG]   [createConnection(sshopsmanager,config)] Home path: /home/ubuntu
[DEBUG]   [createConnection(sshopsmanager,config)] Environment: []
[DEBUG]   Starting shell for sshopsmanager: cd "/home/ubuntu"; $SHELL
[DEBUG]   Terminal session closed: {"code":1,"status":"open"}
[INFO]    Closing connection to 'sshopsmanager' with 'Idle with no active filesystems/terminals' as reason

I'm not sure if this issue is caused by the following: https://github.com/SchoofsKelvin/vscode-sshfs#remote-shell-tasks

Kind regards, Mike

SchoofsKelvin commented 2 years ago

Where is this bosh command declared? Is it part of the PATH variable? (and if so, where does it get appended to PATH?) or like a bash function declared in some profile script? This might be some kind of issue where bash doesn't properly load some profile script (or there's an early return in it) where this command is (indirectly) defined.

Taking a look at your first output again, does Expected non-empty Director URL not mean the command did run, but just failed for some reason? Based on this and this, it's more likely some profile injects $BOSH_ENVIRONMENT but doesn't this time for some reason, perhaps it not being a login shell. You could try changing Terminal command in your config's settings to /bin/bash -l, which might solve the issue with certain profile scripts not (fully) being run.

MikeK184 commented 2 years ago

Hi @SchoofsKelvin,

the change /bin/bash -l solved the issue. And yes you were right, the command did get executed per se but expected more parameters for some reason. I've quickly checked and bosh was within the PATH variable (at the end; last one). Anyway, thanks for your quick help!