Natizyskunk / vscode-sftp

Super fast sftp/ftp extension for VS Code
Other
373 stars 68 forks source link

Connection hop not working #468

Open kleingeo opened 5 months ago

kleingeo commented 5 months ago

Trying to setup connection hopping as a way to proxy jump. I'm on Win 11 and using the latest versions of the extension/VScode.

{
    "name": "Remote Server",
    "protocol": "sftp",
    "port": 22,
    "uploadOnSave": true,
    "ignore": [".vscode", ".git", ".DS_Store", ".idea", ".svn", ".cvs", ".hg", "*.hprof", "*.pyc", "*.nii", "*.nii.gz"],
    "remotePath": "/path/on/host_b",

    "host": "ip_host_a",
    "username": "username_a",
    "privateKeyPath": "~/.ssh/ssh_key_local_to_host_a",

    "hop": {
      "host": "host_b",
      "username": "username_b",
      "privateKeyPath": "~/.ssh/ssh_key_host_a_to_b"}
}

Error output

[01-24 11:51:29] [error] Error: (SSH) Channel open failure: Connection timed out
    at onChannelOpenFailure (c:\Users\GeoffKlein\.vscode\extensions\natizyskunk.sftp-1.16.3\node_modules\ssh2\lib\utils.js:16:11)
    at CHANNEL_OPEN_FAILURE (c:\Users\GeoffKlein\.vscode\extensions\natizyskunk.sftp-1.16.3\node_modules\ssh2\lib\client.js:572:11)
    at 92 (c:\Users\GeoffKlein\.vscode\extensions\natizyskunk.sftp-1.16.3\node_modules\ssh2\lib\protocol\handlers.misc.js:881:16)
    at Protocol.onPayload (c:\Users\GeoffKlein\.vscode\extensions\natizyskunk.sftp-1.16.3\node_modules\ssh2\lib\protocol\Protocol.js:2052:10)
    at GenericDecipherNative.decrypt (c:\Users\GeoffKlein\.vscode\extensions\natizyskunk.sftp-1.16.3\node_modules\ssh2\lib\protocol\crypto.js:1269:26)
    at Protocol.parsePacket [as _parse] (c:\Users\GeoffKlein\.vscode\extensions\natizyskunk.sftp-1.16.3\node_modules\ssh2\lib\protocol\Protocol.js:2021:25)
    at Protocol.parse (c:\Users\GeoffKlein\.vscode\extensions\natizyskunk.sftp-1.16.3\node_modules\ssh2\lib\protocol\Protocol.js:306:16)
    at Socket.<anonymous> (c:\Users\GeoffKlein\.vscode\extensions\natizyskunk.sftp-1.16.3\node_modules\ssh2\lib\client.js:775:21)
    at Socket.emit (node:events:513:28)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:297:9)
    at Socket.Readable.push (node:internal/streams/readable:234:10)
    at TCP.onStreamRead (node:internal/stream_base_commons:190:23) download D:\VertDetect\test_compile.py
[01-24 11:51:29] [error] Error: (SSH) Channel open failure: Connection timed out
    at onChannelOpenFailure (c:\Users\GeoffKlein\.vscode\extensions\natizyskunk.sftp-1.16.3\node_modules\ssh2\lib\utils.js:16:11)
    at CHANNEL_OPEN_FAILURE (c:\Users\GeoffKlein\.vscode\extensions\natizyskunk.sftp-1.16.3\node_modules\ssh2\lib\client.js:572:11)
    at 92 (c:\Users\GeoffKlein\.vscode\extensions\natizyskunk.sftp-1.16.3\node_modules\ssh2\lib\protocol\handlers.misc.js:881:16)
    at Protocol.onPayload (c:\Users\GeoffKlein\.vscode\extensions\natizyskunk.sftp-1.16.3\node_modules\ssh2\lib\protocol\Protocol.js:2052:10)
    at GenericDecipherNative.decrypt (c:\Users\GeoffKlein\.vscode\extensions\natizyskunk.sftp-1.16.3\node_modules\ssh2\lib\protocol\crypto.js:1269:26)
    at Protocol.parsePacket [as _parse] (c:\Users\GeoffKlein\.vscode\extensions\natizyskunk.sftp-1.16.3\node_modules\ssh2\lib\protocol\Protocol.js:2021:25)
    at Protocol.parse (c:\Users\GeoffKlein\.vscode\extensions\natizyskunk.sftp-1.16.3\node_modules\ssh2\lib\protocol\Protocol.js:306:16)
    at Socket.<anonymous> (c:\Users\GeoffKlein\.vscode\extensions\natizyskunk.sftp-1.16.3\node_modules\ssh2\lib\client.js:775:21)
    at Socket.emit (node:events:513:28)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:297:9)
    at Socket.Readable.push (node:internal/streams/readable:234:10)
    at TCP.onStreamRead (node:internal/stream_base_commons:190:23) download D:\VertDetect\test_compile.py

The connections are setup properly. I am able to ssh from local -> host_a and from host_a -> host_b easily. I can also do it in one step with local ssh config file, but not sure how to utilize that. image

codivist commented 2 months ago

+1

codivist commented 2 months ago

My debug output a little different saying Channel open failure: Name or service not known

[04-17 14:39:21] [error] Error: (SSH) Channel open failure: Name or service not known
    at onChannelOpenFailure (/Users/username/.vscode/extensions/natizyskunk.sftp-1.16.3/node_modules/ssh2/lib/utils.js:16:11)
    at CHANNEL_OPEN_FAILURE (/Users/username/.vscode/extensions/natizyskunk.sftp-1.16.3/node_modules/ssh2/lib/client.js:572:11)
    at 92 (/Users/username/.vscode/extensions/natizyskunk.sftp-1.16.3/node_modules/ssh2/lib/protocol/handlers.misc.js:881:16)
    at Protocol.onPayload (/Users/username/.vscode/extensions/natizyskunk.sftp-1.16.3/node_modules/ssh2/lib/protocol/Protocol.js:2052:10)
    at AESGCMDecipherNative.decrypt (/Users/username/.vscode/extensions/natizyskunk.sftp-1.16.3/node_modules/ssh2/lib/protocol/crypto.js:987:26)
    at Protocol.parsePacket [as _parse] (/Users/username/.vscode/extensions/natizyskunk.sftp-1.16.3/node_modules/ssh2/lib/protocol/Protocol.js:2021:25)
    at Protocol.parse (/Users/username/.vscode/extensions/natizyskunk.sftp-1.16.3/node_modules/ssh2/lib/protocol/Protocol.js:306:16)
    at Socket.<anonymous> (/Users/username/.vscode/extensions/natizyskunk.sftp-1.16.3/node_modules/ssh2/lib/client.js:775:21)
    at Socket.emit (node:events:514:28)
    at Socket.emit (node:domain:489:12)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:297:9)
    at Socket.push (node:internal/streams/readable:234:10)
    at TCP.onStreamRead (node:internal/stream_base_commons:190:23)
codivist commented 2 months ago

so after much testing and trying different settings. This does work, but you have to use the full domain in the hop (target) definition.

I have sites setup in my config locally and in the server that I'm hoping from and it doesn't work when using the name from the config file.

kleingeo commented 2 months ago

so after much testing and trying different settings. This does work, but you have to use the full domain in the hop (target) definition.

I have sites setup in my config locally and in the server that I'm hoping from and it doesn't work when using the name from the config file.

Can you link your setup config file you are using to get it working (even with dummy IP addresses). I am also using full addresses but I am still having trouble.

codivist commented 2 months ago
{
    "name": "serverDev1",

    "host": "office",
    "protocol": "sftp",
    "port": 22,
    "username": "username",
    "privateKeyPath": "/Users/username/.ssh/office_rsa",
    "remotePath": "/shared/accounts/t/testingServer/dev1.example.com",

    "hop": {
        "host": "dev1.example.com",
        "protocol": "sftp",
        "port": 22,
        "username": "username",
        "privateKeyPath": "/storage/home/username/.ssh/dev1_rsa"
    },

    "downloadOnOpen": true,
    "uploadOnSave": true,
    "useTempFile": false,

    "ignore": [
        "/some/folder/with/ignored/files"
    ]
}

So our "office" server is where I'm hopping through and I have an entry in my .ssh/config file that handles the connection from my computer to the office server.

In the hop definition is where I have to use a full domain on the host (even though I have a .ssh/config on the office server to handle it. I also noticed that it needed the protocol AND port in the hop definition for it to connect to the final server. Also, just in case, either password or privateKeyPath worked in my testing in the hop definition

Hopefully that helps.

kleingeo commented 2 months ago

I also noticed that it needed the protocol AND port in the hop definition for it to connect to the final server.

Yep, I didn't have protocol in the hop. That's what fixed it in the end.