question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to connect to SFTP

See original GitHub issue

I have the following config in my sftp.json inside the .vscode folder:

{
  "protocol": "sftp",
  "host": "host.com",
  "port": 2222,
  "username": "username",
  "password": "pass"
}

But when I try to connect the connection is always getting timed out. On the other hand when I use the exact same details in FileZilla it works perfectly. In FileZilla after I connect, I get a popup like this which I need to accept in order to connect:

Filezilla screenshot

But there is no such thing in the vs code extension. Also previously when I used the liximomo version of the extension, I never had this issue. After I uninstalled that extension and installed this one, I can see this issue.

I have also enabled the SFTP log to see what’s going on and I see this in the log:

[07-08 14:08:37] [debug] Custom crypto binding not available
[07-08 14:08:37] [debug] Client: Trying ftp.sescollege.org on port 2222 ...
[07-08 14:08:37] [debug] Local ident: 'SSH-2.0-ssh2js1.1.0'
[07-08 14:08:38] [debug] Socket connected
[07-08 14:08:38] [debug] Remote ident: 'SSH-2.0-OpenSSH_5.3'
[07-08 14:08:38] [debug] Outbound: Sending KEXINIT
[07-08 14:08:38] [debug] Inbound: Handshake in progress
[07-08 14:08:38] [debug] Handshake: (local) KEX method: curve25519-sha256@libssh.org,curve25519-sha256,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group15-sha512,diffie-hellman-group16-sha512,diffie-hellman-group17-sha512,diffie-hellman-group18-sha512
[07-08 14:08:38] [debug] Handshake: (remote) KEX method: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
[07-08 14:08:38] [debug] Handshake: KEX algorithm: diffie-hellman-group-exchange-sha256
[07-08 14:08:38] [debug] Handshake: (local) Host key format: ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,rsa-sha2-512,rsa-sha2-256,ssh-rsa
[07-08 14:08:38] [debug] Handshake: (remote) Host key format: ssh-rsa,ssh-dss
[07-08 14:08:38] [debug] Handshake: Host key format: ssh-rsa
[07-08 14:08:38] [debug] Handshake: (local) C->S cipher: aes128-gcm,aes128-gcm@openssh.com,aes256-gcm,aes256-gcm@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,chacha20-poly1305@openssh.com
[07-08 14:08:38] [debug] Handshake: (remote) C->S cipher: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
[07-08 14:08:38] [debug] Handshake: C->S Cipher: aes128-ctr
[07-08 14:08:38] [debug] Handshake: (local) S->C cipher: aes128-gcm,aes128-gcm@openssh.com,aes256-gcm,aes256-gcm@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,chacha20-poly1305@openssh.com
[07-08 14:08:38] [debug] Handshake: (remote) S->C cipher: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
[07-08 14:08:38] [debug] Handshake: S->C cipher: aes128-ctr
[07-08 14:08:38] [debug] Handshake: (local) C->S MAC: hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
[07-08 14:08:38] [debug] Handshake: (remote) C->S MAC: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
[07-08 14:08:38] [debug] Handshake: C->S MAC: hmac-sha2-256
[07-08 14:08:38] [debug] Handshake: (local) S->C MAC: hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
[07-08 14:08:38] [debug] Handshake: (remote) S->C MAC: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
[07-08 14:08:38] [debug] Handshake: S->C MAC: hmac-sha2-256
[07-08 14:08:38] [debug] Handshake: (local) C->S compression: none,zlib@openssh.com,zlib
[07-08 14:08:38] [debug] Handshake: (remote) C->S compression: none,zlib@openssh.com
[07-08 14:08:38] [debug] Handshake: C->S compression: none
[07-08 14:08:38] [debug] Handshake: (local) S->C compression: none,zlib@openssh.com,zlib
[07-08 14:08:38] [debug] Handshake: (remote) S->C compression: none,zlib@openssh.com
[07-08 14:08:38] [debug] Handshake: S->C compression: none
[07-08 14:08:38] [debug] Outbound: Sending KEXDH_GEX_REQUEST
[07-08 14:08:38] [debug] Received DH GEX Group
[07-08 14:09:07] [debug] Outbound: Sending KEXDH_GEX_INIT
[07-08 14:09:07] [debug] Outbound: Sending DISCONNECT (11)
[07-08 14:09:07] [debug] Socket closed

Do you have any clue on how to resolve this matter so that I can use the extension?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:18 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
Mickeywaughcommented, Aug 25, 2021

@Natizyskunk as your advise above, the algorithms configuration seems works with issue 1.15.2, good job! TKS!

1reaction
Natizyskunkcommented, Aug 25, 2021

@Mickeywaugh,

Can you try this please ?

FAQ : https://github.com/Natizyskunk/vscode-sftp/blob/master/FAQ.md#error-connection-closed

The problem would be that the SFTP extension keeps closing the connection for those who use more legacy/old systems. You’ll have to Explicitly override the default transport layer algorithms used for the connection to remove the new “diffie-hellman-group-exchange-sha256” algorithm that cause the problem from the kex section. Just add this in your sftp.json config file, which should make it work.

{
	...
	"host": "exemple.com",
	...
	"algorithms": {
		"kex": [
			"ecdh-sha2-nistp256", 
			"ecdh-sha2-nistp384", 
			"ecdh-sha2-nistp521", 
			"diffie-hellman-group14-sha1"
		],
		"cipher": [
			"aes128-ctr", 
			"aes192-ctr", 
			"aes256-ctr", 
			"aes128-gcm", 
			"aes128-gcm@openssh.com", 
			"aes256-gcm", 
			"aes256-gcm@openssh.com"
		],
		"serverHostKey": [
			"ssh-rsa", 
			"ecdsa-sha2-nistp256", 
			"ecdsa-sha2-nistp384", 
			"ecdsa-sha2-nistp521"
		],
		"hmac": [
			"hmac-sha2-256", 
			"hmac-sha2-512", 
			"hmac-sha1"
		]
	}
}

References: _Originally posted by @montorodiaz in https://github.com/liximomo/vscode-sftp/issues/883#issuecomment-783402096_ https://github.com/liximomo/vscode-sftp/wiki/SFTP-only-Config#sshcustomparams

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does SFTP (FTP) Fail to Connect? - Servebolt.com
Why does SFTP (FTP) Fail to Connect? · Make sure you're using SFTP. · Make sure you use port 1022 , many SFTP...
Read more >
Troubleshooting SFTP Connection Errors and Problems
Having difficultly connecting to the server with your SFTP program? See the simple steps involved to get reconnected again.
Read more >
How do I solve the "Unable to Connect To Server" error?
Click on your "Start" button in the lower left corner of your screen. · Selecting "Run ..." option from the Start Menu. ·...
Read more >
Finding out what happened that I cannot connect to SFTP ...
All of a sudden, the console app cannot connect to this SFTP server. I confirmed this issue with filezilla. Our tech support says...
Read more >
Troubleshooting SFTP Connections
Verify that the server you are connecting to supports SFTP connections (see Note below). · Verify the connection port. · Try toggling the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found