vscode-sshfs icon indicating copy to clipboard operation
vscode-sshfs copied to clipboard

I can access to remote server by terminal , but sshfs report a error

Open mikev4 opened this issue 3 years ago • 4 comments

I can access to remote server via terminal , but sshfs 图片

via terminal login successfully 图片

myconfig 图片

it too slow that I spend about 30s connect to remote server by terminal , I guess it is timeout via sshfs plugin? its there any params can config connection timeout? look likeconnectionTimeout maybe thx for your help

error info 图片

mikev4 avatar Nov 19 '21 09:11 mikev4

This issue would be easier to solve with debug logs, so please follow these steps:

  • Add DEBUG_SSH2 to the sshfs.flags array in VS Code's User Settings (settings.json) e.g. "sshfs.flags": ["DEBUG_SSH2"]
    • See this issue for more information about adding flags
  • If you already have a connection open, close it completely (or even reload the window)
  • Go to Output > SSH FS and copy the log from there after replicating your bug
  • While it should censor passwords/passphrases, I recommend checking it for (other) sensitive data first. (especially since DEBUG_SSH2 activates some internal logging, which is less likely to be censored)

SchoofsKelvin avatar Nov 21 '21 16:11 SchoofsKelvin

@SchoofsKelvin this is my log

[INFO]    Loading configurations...
[INFO]    Calculated config flags: {"debug_ssh2":[null,"Global Settings"]}
[DEBUG]   	Added configuration sshconfig from [1]
[INFO]    Found 1 configurations
[INFO]    Extension activated, version 1.24.0, mode 2
[INFO]    Command received to open a terminal for FileSystemConfig(sshconfig)
[INFO]    [createConnection(sshconfig,config)] Creating a new connection for 'sshconfig'
[INFO]    Calculating actual config
[DEBUG]   	Final configuration:
{
    "name": "sshconfig",
    "host": "172.17.0.2",
    "root": "/",
    "username": "root",
    "password": "<censored>",
    "_location": 1,
    "_locations": [
        1
    ],
    "_calculated": {
        "name": "sshconfig",
        "host": "172.17.0.2",
        "root": "/",
        "username": "root",
        "password": "<censored>",
        "_location": 1,
        "_locations": [
            1
        ]
    },
    "port": 22
}
[INFO]    [createSocket(sshconfig)] Creating socket
[DEBUG]   [createSocket(sshconfig)] Connecting to 172.17.0.2:22
[DEBUG]   [ssh2(sshconfig)] DEBUG: Local ident: 'SSH-2.0-ssh2js0.4.10'
[DEBUG]   [ssh2(sshconfig)] DEBUG: Parser: IN_INIT
[DEBUG]   [ssh2(sshconfig)] DEBUG: Parser: IN_GREETING
[DEBUG]   [ssh2(sshconfig)] DEBUG: Parser: IN_HEADER
[DEBUG]   [ssh2(sshconfig)] DEBUG: Remote ident: 'SSH-2.0-OpenSSH_7.4'
[DEBUG]   [ssh2(sshconfig)] DEBUG: Outgoing: Writing KEXINIT
[DEBUG]   [ssh2(sshconfig)] DEBUG: Parser: IN_PACKETBEFORE (expecting 8)
[DEBUG]   [ssh2(sshconfig)] DEBUG: Parser: IN_PACKET
[DEBUG]   [ssh2(sshconfig)] DEBUG: Parser: pktLen:1276,padLen:10,remainLen:1272
[DEBUG]   [ssh2(sshconfig)] DEBUG: Parser: IN_PACKETDATA
[DEBUG]   [ssh2(sshconfig)] DEBUG: Parser: IN_PACKETDATAAFTER, packet: KEXINIT
[DEBUG]   [ssh2(sshconfig)] DEBUG: Comparing KEXINITs ...
[DEBUG]   [ssh2(sshconfig)] DEBUG: (local) KEX algorithms: [email protected],curve25519-sha256,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha1
[DEBUG]   [ssh2(sshconfig)] DEBUG: (remote) KEX algorithms: curve25519-sha256,[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
[DEBUG]   [ssh2(sshconfig)] DEBUG: KEX algorithm: [email protected]
[DEBUG]   [ssh2(sshconfig)] DEBUG: (local) Host key formats: ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-rsa
[DEBUG]   [ssh2(sshconfig)] DEBUG: (remote) Host key formats: ssh-rsa,rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp256,ssh-ed25519
[DEBUG]   [ssh2(sshconfig)] DEBUG: Host key format: ssh-ed25519
[DEBUG]   [ssh2(sshconfig)] DEBUG: (local) Client->Server ciphers: aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm,[email protected],aes256-gcm,[email protected]
[DEBUG]   [ssh2(sshconfig)] DEBUG: (remote) Client->Server ciphers: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected],aes128-cbc,aes192-cbc,aes256-cbc,blowfish-cbc,cast128-cbc,3des-cbc
[DEBUG]   [ssh2(sshconfig)] DEBUG: Client->Server Cipher: aes128-ctr
[DEBUG]   [ssh2(sshconfig)] DEBUG: (local) Server->Client ciphers: aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm,[email protected],aes256-gcm,[email protected]
[DEBUG]   [ssh2(sshconfig)] DEBUG: (remote) Server->Client ciphers: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected],aes128-cbc,aes192-cbc,aes256-cbc,blowfish-cbc,cast128-cbc,3des-cbc
[DEBUG]   [ssh2(sshconfig)] DEBUG: Server->Client Cipher: aes128-ctr
[DEBUG]   [ssh2(sshconfig)] DEBUG: (local) Client->Server HMAC algorithms: hmac-sha2-256,hmac-sha2-512,hmac-sha1
[DEBUG]   [ssh2(sshconfig)] DEBUG: (remote) Client->Server HMAC algorithms: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
[DEBUG]   [ssh2(sshconfig)] DEBUG: Client->Server HMAC algorithm: hmac-sha2-256
[DEBUG]   [ssh2(sshconfig)] DEBUG: (local) Server->Client HMAC algorithms: hmac-sha2-256,hmac-sha2-512,hmac-sha1
[DEBUG]   [ssh2(sshconfig)] DEBUG: (remote) Server->Client HMAC algorithms: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1
[DEBUG]   [ssh2(sshconfig)] DEBUG: Server->Client HMAC algorithm: hmac-sha2-256
[DEBUG]   [ssh2(sshconfig)] DEBUG: (local) Client->Server compression algorithms: none,[email protected],zlib
[DEBUG]   [ssh2(sshconfig)] DEBUG: (remote) Client->Server compression algorithms: none,[email protected]
[DEBUG]   [ssh2(sshconfig)] DEBUG: Client->Server compression algorithm: none
[DEBUG]   [ssh2(sshconfig)] DEBUG: (local) Server->Client compression algorithms: none,[email protected],zlib
[DEBUG]   [ssh2(sshconfig)] DEBUG: (remote) Server->Client compression algorithms: none,[email protected]
[DEBUG]   [ssh2(sshconfig)] DEBUG: Server->Client compression algorithm: none
[DEBUG]   [ssh2(sshconfig)] DEBUG: Outgoing: Writing KEXECDH_INIT
[DEBUG]   [ssh2(sshconfig)] DEBUG: Parser: IN_PACKETBEFORE (expecting 8)
[DEBUG]   [ssh2(sshconfig)] DEBUG: Parser: IN_PACKET
[DEBUG]   [ssh2(sshconfig)] DEBUG: Parser: pktLen:188,padLen:8,remainLen:184
[DEBUG]   [ssh2(sshconfig)] DEBUG: Parser: IN_PACKETDATA
[DEBUG]   [ssh2(sshconfig)] DEBUG: Parser: IN_PACKETDATAAFTER, packet: KEXECDH_REPLY
[DEBUG]   [ssh2(sshconfig)] DEBUG: Checking host key format
[DEBUG]   [ssh2(sshconfig)] DEBUG: Checking signature format
[DEBUG]   [ssh2(sshconfig)] DEBUG: Verifying host fingerprint
[DEBUG]   [ssh2(sshconfig)] DEBUG: Host accepted by default (no verification)
[DEBUG]   [ssh2(sshconfig)] DEBUG: Verifying signature
[DEBUG]   [ssh2(sshconfig)] DEBUG: Outgoing: Writing NEWKEYS
[DEBUG]   [ssh2(sshconfig)] DEBUG: Parser: IN_PACKETBEFORE (expecting 8)
[DEBUG]   [ssh2(sshconfig)] DEBUG: Parser: IN_PACKET
[DEBUG]   [ssh2(sshconfig)] DEBUG: Parser: pktLen:12,padLen:10,remainLen:8
[DEBUG]   [ssh2(sshconfig)] DEBUG: Parser: IN_PACKETDATA
[DEBUG]   [ssh2(sshconfig)] DEBUG: Parser: IN_PACKETDATAAFTER, packet: NEWKEYS
[DEBUG]   [ssh2(sshconfig)] DEBUG: Outgoing: Writing SERVICE_REQUEST (ssh-userauth)
[DEBUG]   [ssh2(sshconfig)] DEBUG: Parser: IN_PACKETBEFORE (expecting 16)
[DEBUG]   [ssh2(sshconfig)] DEBUG: Parser: IN_PACKET
[DEBUG]   [ssh2(sshconfig)] DEBUG: Parser: Decrypting
[DEBUG]   [ssh2(sshconfig)] DEBUG: Parser: pktLen:28,padLen:10,remainLen:16
[DEBUG]   [ssh2(sshconfig)] DEBUG: Parser: IN_PACKETDATA
[DEBUG]   [ssh2(sshconfig)] DEBUG: Parser: Decrypting
[DEBUG]   [ssh2(sshconfig)] DEBUG: Parser: HMAC size:32
[DEBUG]   [ssh2(sshconfig)] DEBUG: Parser: IN_PACKETDATAVERIFY
[DEBUG]   [ssh2(sshconfig)] DEBUG: Parser: Verifying MAC
[DEBUG]   [ssh2(sshconfig)] DEBUG: Parser: IN_PACKETDATAVERIFY (Valid HMAC)
[DEBUG]   [ssh2(sshconfig)] DEBUG: Parser: IN_PACKETDATAAFTER, packet: SERVICE_ACCEPT
[DEBUG]   [ssh2(sshconfig)] DEBUG: Outgoing: Writing USERAUTH_REQUEST (none)
[DEBUG]   [ssh2(sshconfig)] DEBUG: Parser: IN_PACKETBEFORE (expecting 16)
[ERROR]   [createSSH(sshconfig)] Error: Timed out while waiting for handshake
JSON: {"level":"client-timeout"}
Error: Timed out while waiting for handshake
	at Timeout._onTimeout (/home/coder/.local/share/code-server/extensions/kelvin.vscode-sshfs-1.24.0/dist/14f8.extension.js:1:257524)
	at listOnTimeout (internal/timers.js:557:17)
	at processTimers (internal/timers.js:500:7)
Logged at:
	at T.emit (events.js:400:28)
	at Timeout._onTimeout (/home/coder/.local/share/code-server/extensions/kelvin.vscode-sshfs-1.24.0/dist/14f8.extension.js:1:257602)
	at listOnTimeout (internal/timers.js:557:17)
	at processTimers (internal/timers.js:500:7)
Reported by logger createSSH(sshconfig)
[ERROR]   Error while creating terminal:
Error: Timed out while waiting for handshake
JSON: {"level":"client-timeout"}
Error: Timed out while waiting for handshake
	at Timeout._onTimeout (/home/coder/.local/share/code-server/extensions/kelvin.vscode-sshfs-1.24.0/dist/14f8.extension.js:1:257524)
	at listOnTimeout (internal/timers.js:557:17)
	at processTimers (internal/timers.js:500:7)
Logged at:
	at m.commandTerminal (/home/coder/.local/share/code-server/extensions/kelvin.vscode-sshfs-1.24.0/dist/extension.js:11:26256)
	at processTicksAndRejections (internal/process/task_queues.js:95:5)
	at async _executeContributedCommand (/usr/lib/code-server/vendor/modules/code-oss-dev/out/vs/workbench/services/extensions/node/extensionHostProcess.js:94:110871)

mikev4 avatar Nov 22 '21 03:11 mikev4

Does it take a long time when you authenticate using ssh or similar, e.g. by not using the extension?

I'll have to check the source code of the ssh2 library in detail to check something, but my first idea looking at your log is that your sshd server seems to not respond to a none authentication request? I'm not sure if you've configured anything regarding this or whether your server is busy querying some authentication data. Perhaps the sshd logs (with a debug log level) might tell you more (bit of a security risk to post those) as to what's happening after it receives the authentication request.

In the meantime, I'll see about creating a build of the extension with none disabled. Pretty sure the ssh2 library can be coerced to skip that.

SchoofsKelvin avatar Nov 23 '21 22:11 SchoofsKelvin

Could you try out the .vsix from the latest build here? It'll try password > agent > publickey (aka privateKey) > keyboard-interactive > none, in that order, skipping the ones it can't do (e.g. password without a password set). If the issue is with your server mishandling none, this build should fix your issue and give me an idea of how to properly solve it for public release.

SchoofsKelvin avatar Dec 03 '21 15:12 SchoofsKelvin