Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use .ssh/config alias with HostName #396

Closed
1 of 2 tasks
RixzZ opened this issue Nov 15, 2018 · 15 comments
Closed
1 of 2 tasks

Can't use .ssh/config alias with HostName #396

RixzZ opened this issue Nov 15, 2018 · 15 comments

Comments

@RixzZ
Copy link

RixzZ commented Nov 15, 2018

Do you read the FAQ?

Describe the bug
If I try to connect to a host defined on my .ssh/config when an alias (and a HostName), the plugin replies with: getaddrinfo ENOTFOUND.
I can use the same alias with SSH and it works just fine.

To Reproduce
Steps to reproduce the behavior:

  1. Create an entry in your .ssh/config using a non-address alias as "Host" and the correct server address in "HostName"
  2. Configure it on the VSCode SFTP plugin.
  3. Try to do anything that uses that SFTP connection.
  4. See error.

Expected behavior
The plugin should connect correctly when using the SSH_AGENT and the configuration from .ssh/config.

Current SFTP config

{
    "protocol": "sftp",
    "host": "rpi-rsa",
    "port": 22,
    "username": "rpi",
    "remotePath": "/home/pi/Test",
    "agent": "$SSH_AUTH_SOCK"
}

Current .ssh/config section for that Host:

Host rpi-rsa
    HostName XXXXX.XXXXX.XXX
    User pi
    IdentityFile ~/.ssh/id_rsa-personal

Desktop (please complete the following information):

  • OS: Tried on Mac and Linux
  • VSCode Version 1.29.0
  • Extension Version 1.7.5

Extension Logs - required

[info] config at /home/rixzz/Documents/Git/XXXXXXXX {"remotePath":"/home/pi/Test","uploadOnSave":false,"downloadOnOpen":false,"ignore":[],"concurrency":4,"protocol":"sftp","connectTimeout":10000,"interactiveAuth":false,"secure":false,"passive":false,"remoteTimeOffsetInHours":0,"port":22,"host":"rpi-rsa","username":"******","agent":"$SSH_AUTH_SOCK","user":"pi","privatekey":"~/.ssh/id_rsa-personal"}
[trace] run command 'Upload Project'
[trace] handle upload folder for /home/rixzz/Documents/Git/XXXXXXXX
[debug] Local ident: 'SSH-2.0-ssh2js0.2.1'
[debug] Client: Trying rpi-rsa on port 22 ...
[error] Error: [rpi-rsa]: getaddrinfo ENOTFOUND rpi-rsa rpi-rsa:22
	at Client.client.on.on.err (/home/rixzz/.vscode/extensions/liximomo.sftp-1.7.5/out/src/core/remote-client/sshClient.js:229:28)
	at emitOne (events.js:121:20)
	at Client.emit (events.js:211:7)
	at Socket.<anonymous> (/home/rixzz/.vscode/extensions/liximomo.sftp-1.7.5/node_modules/ssh2/lib/client.js:300:10)
	at emitOne (events.js:116:13)
	at Socket.emit (events.js:211:7)
	at emitErrorNT (internal/streams/destroy.js:64:8)
	at _combinedTickCallback (internal/process/next_tick.js:138:11)
	at process._tickCallback (internal/process/next_tick.js:180:9) 
@liximomo
Copy link
Owner

Please try 1.7.6-debug.

@RixzZ
Copy link
Author

RixzZ commented Nov 16, 2018

Hello.

Thanks for your reply. I just tried with the 1.7.6-debug version and same result. I'll attach the logs with debug enabled:

[trace] run command 'Upload Project'
[trace] handle upload folder for /home/rixzz/Documents/Git/XXXXXXXX
[debug] Local ident: 'SSH-2.0-ssh2js0.2.1'
[debug] Client: Trying rpi-rsa on port 22 ...
[error] Error: [rpi-rsa]: getaddrinfo ENOTFOUND rpi-rsa rpi-rsa:22
	at B.e.on.on.e (/home/rixzz/.vscode/extensions/liximomo.sftp-1.7.6-debug/dist/extension.js:70:102276)
	at emitOne (events.js:121:20)
	at B.emit (events.js:211:7)
	at Socket.<anonymous> (/home/rixzz/.vscode/extensions/liximomo.sftp-1.7.6-debug/dist/extension.js:70:111677)
	at emitOne (events.js:116:13)
	at Socket.emit (events.js:211:7)
	at emitErrorNT (internal/streams/destroy.js:64:8)
	at _combinedTickCallback (internal/process/next_tick.js:138:11)
	at process._tickCallback (internal/process/next_tick.js:180:9) 

Anything else I can try?

@liximomo
Copy link
Owner

liximomo commented Nov 16, 2018

@RixzZ Try 1.7.6-debug.1.

@RixzZ
Copy link
Author

RixzZ commented Nov 16, 2018

Hello.

Same thing :/

[info] config at /home/rixzz/Documents/Git/XXXXXXXX {"remotePath":"/home/pi/Test","uploadOnSave":false,"downloadOnOpen":false,"ignore":[],"concurrency":4,"protocol":"sftp","connectTimeout":10000,"interactiveAuth":false,"secure":false,"passive":false,"remoteTimeOffsetInHours":0,"port":22,"host":"rpi-rsa","username":"******","agent":"$SSH_AUTH_SOCK"}
[trace] run command 'Upload Project'
[trace] handle upload folder for /home/rixzz/Documents/Git/XXXXXXXX
[debug] Local ident: 'SSH-2.0-ssh2js0.2.1'
[debug] Client: Trying rpi-rsa on port 22 ...
[error] Error: [rpi-rsa]: getaddrinfo ENOTFOUND rpi-rsa rpi-rsa:22
	at B.e.on.on.e (/home/rixzz/.vscode/extensions/liximomo.sftp-1.7.6-debug.1/dist/extension.js:70:102276)
	at emitOne (events.js:121:20)
	at B.emit (events.js:211:7)
	at Socket.<anonymous> (/home/rixzz/.vscode/extensions/liximomo.sftp-1.7.6-debug.1/dist/extension.js:70:111677)
	at emitOne (events.js:116:13)
	at Socket.emit (events.js:211:7)
	at emitErrorNT (internal/streams/destroy.js:64:8)
	at _combinedTickCallback (internal/process/next_tick.js:138:11)
	at process._tickCallback (internal/process/next_tick.js:180:9) 

@liximomo
Copy link
Owner

@RixzZ I think this is still the old version. Try to uninstall sftp-debug and quit vscode and reinstall.

@RixzZ
Copy link
Author

RixzZ commented Nov 16, 2018

Oh, okay. Now the log is bigger:

[debug] find config for rpi-rsa  { type: 1,
  param: 'Host',
  separator: ' ',
  value: 'rpi-rsa',
  before: '',
  after: '\n',
  config: 
   l [
     { type: 1,
       param: 'User',
       separator: ' ',
       value: 'pi',
       before: '    ',
       after: '\n' },
     { type: 1,
       param: 'IdentityFile',
       separator: ' ',
       value: '~/.ssh/id_rsa-personal',
       before: '    ',
       after: '\n\n' } ] }
[debug] ssh config: user User pi
[debug] ssh config: privatekey IdentityFile ~/.ssh/id_rsa-personal
[info] config at /home/rixzz/Documents/Git/XXXXXX {"remotePath":"/home/pi/Test","uploadOnSave":false,"downloadOnOpen":false,"ignore":[],"concurrency":4,"protocol":"sftp","connectTimeout":10000,"interactiveAuth":false,"secure":false,"passive":false,"remoteTimeOffsetInHours":0,"port":22,"host":"rpi-rsa","username":"******","agent":"$SSH_AUTH_SOCK","user":"pi","privatekey":"~/.ssh/id_rsa-personal"}
[trace] run command 'Upload Project'
[trace] handle upload folder for /home/rixzz/Documents/Git/XXXXXX
[debug] Local ident: 'SSH-2.0-ssh2js0.2.1'
[debug] Client: Trying rpi-rsa on port 22 ...
[error] Error: [rpi-rsa]: getaddrinfo ENOTFOUND rpi-rsa rpi-rsa:22
	at B.e.on.on.e (/home/rixzz/.vscode/extensions/liximomo.sftp-1.7.6-debug.1/dist/extension.js:70:102276)
	at emitOne (events.js:121:20)
	at B.emit (events.js:211:7)
	at Socket.<anonymous> (/home/rixzz/.vscode/extensions/liximomo.sftp-1.7.6-debug.1/dist/extension.js:70:111677)
	at emitOne (events.js:116:13)
	at Socket.emit (events.js:211:7)
	at emitErrorNT (internal/streams/destroy.js:64:8)
	at _combinedTickCallback (internal/process/next_tick.js:138:11)
	at process._tickCallback (internal/process/next_tick.js:180:9) 

Seems like it can see the config at least.

I don't know if this is important, but on this PC, right now I also apply this settings for all connections:

UserKnownHostsFile /dev/null
StrictHostKeyChecking no
GSSAPIAuthentication no
IdentitiesOnly yes
AddKeysToAgent yes
SendEnv LANG LC_*
LogLevel QUIET

The 'IdentitiesOnly yes' is needed in my case because I have two keys that can access the 'rpi-rsa' server. One ed25519 and one rsa I created for the SFTP plugin since it can't use ed25519.

Maybe the plugin don't see that flag and try to login with the edd25519?

@liximomo
Copy link
Owner

liximomo commented Nov 16, 2018

It can see the config, but only a part of.

config: 
   l [
     { type: 1,
       param: 'User',
       separator: ' ',
       value: 'pi',
       before: '    ',
       after: '\n' },
     { type: 1,
       param: 'IdentityFile',
       separator: ' ',
       value: '~/.ssh/id_rsa-personal',
       before: '    ',
       after: '\n\n' } ] }

It can't see HostName.

BYW, you didn't give the full log. Please provide the full log.

@RixzZ
Copy link
Author

RixzZ commented Nov 16, 2018

Okay, I rechecked the .ssh/config because I have made changes before. Now:

.ssh/config

##################################################

Host rpi-rsa
    HostName REALHOSTNAME
    User pi
    IdentityFile ~/.ssh/id_rsa-personal

Host *
    User root
    UserKnownHostsFile /dev/null
    StrictHostKeyChecking no
    GSSAPIAuthentication no
    IdentitiesOnly yes
    AddKeysToAgent yes
    SendEnv LANG LC_*
    LogLevel QUIET

##################################################

Full log:

[trace] run command 'Upload Project'
[trace] handle upload folder for /home/rixzz/Documents/Git/XXXXXXXX
[debug] Local ident: 'SSH-2.0-ssh2js0.2.1'
[debug] Client: Trying REALHOSTNAME on port 22 ...
[debug] Client: Connected
[debug] Remote ident: 'SSH-2.0-OpenSSH_7.4p1 Raspbian-10+deb9u4'
[debug] Outgoing: Writing KEXINIT
[debug] DEBUG: Comparing KEXINITs ...
[debug] (local) KEX algorithms: ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1
[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-group14-sha256,diffie-hellman-group14-sha1
[debug] KEX algorithm: ecdh-sha2-nistp256
[debug] (local) Host key formats: ssh-rsa,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
[debug] (remote) Host key formats: ssh-rsa,rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp256,ssh-ed25519
[debug] Host key format: ssh-rsa
[debug] (local) Client->Server ciphers: aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm,[email protected],aes256-gcm,[email protected]
[debug] (remote) Client->Server ciphers: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
[debug] Client->Server Cipher: aes128-ctr
[debug] (local) Server->Client ciphers: aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm,[email protected],aes256-gcm,[email protected]
[debug] (remote) Server->Client ciphers: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected]
[debug] Server->Client Cipher: aes128-ctr
[debug] (local) Client->Server HMAC algorithms: hmac-sha2-256,hmac-sha2-512,hmac-sha1
[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] Client->Server HMAC algorithm: hmac-sha2-256
[debug] (local) Server->Client HMAC algorithms: hmac-sha2-256,hmac-sha2-512,hmac-sha1
[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] Server->Client HMAC algorithm: hmac-sha2-256
[debug] (local) Client->Server compression algorithms: none,[email protected],zlib
[debug] (remote) Client->Server compression algorithms: none,[email protected]
[debug] Client->Server compression algorithm: none
[debug] (local) Server->Client compression algorithms: none,[email protected],zlib
[debug] (remote) Server->Client compression algorithms: none,[email protected]
[debug] Server->Client compression algorithm: none
[debug] Outgoing: Writing KEXECDH_INIT
[debug] DEBUG: Checking host key format
[debug] DEBUG: Checking signature format
[debug] DEBUG: Verifying host fingerprint
[debug] DEBUG: Host accepted by default (no verification)
[debug] DEBUG: Verifying signature
[debug] Outgoing: Writing NEWKEYS
[debug] Outgoing: Writing SERVICE_REQUEST (ssh-userauth)
[debug] Outgoing: Writing USERAUTH_REQUEST (none)
[debug] Client: none auth failed
[debug] Outgoing: Writing USERAUTH_REQUEST (publickey -- check)
[debug] Client: Agent key #1 failed
[debug] Agent: Trying key #2
[debug] Outgoing: Writing USERAUTH_REQUEST (publickey -- check)
[debug] Client: Agent key #2 failed
[debug] Agent: Trying key #3
[debug] Outgoing: Writing USERAUTH_REQUEST (publickey -- check)
[debug] Client: Agent key #3 failed
[debug] Agent: Trying key #4
[debug] Outgoing: Writing USERAUTH_REQUEST (publickey -- check)
[debug] Client: Agent key #4 failed
[debug] Agent: Trying key #5
[debug] Outgoing: Writing USERAUTH_REQUEST (publickey -- check)
[debug] Client: Agent key #5 failed
[debug] Agent: No more keys left to try
[debug] Client: agent auth failed
[debug] Outgoing: Writing DISCONNECT (BY_APPLICATION)
[debug] Outgoing: Writing DISCONNECT (BY_APPLICATION)
[debug] Outgoing: Writing DISCONNECT (BY_APPLICATION)
[debug] Outgoing: Writing DISCONNECT (BY_APPLICATION)
[error] Error: [REALHOSTNAME]: All configured authentication methods failed
	at B.e.on.on.e (/home/rixzz/.vscode/extensions/liximomo.sftp-1.7.6-debug.1/dist/extension.js:70:102276)
	at emitOne (events.js:121:20)
	at B.emit (events.js:211:7)
	at M (/home/rixzz/.vscode/extensions/liximomo.sftp-1.7.6-debug.1/dist/extension.js:70:113039)
	at j (/home/rixzz/.vscode/extensions/liximomo.sftp-1.7.6-debug.1/dist/extension.js:70:114395)
	at Ee.W (/home/rixzz/.vscode/extensions/liximomo.sftp-1.7.6-debug.1/dist/extension.js:70:115985)
	at emitTwo (events.js:126:13)
	at Ee.emit (events.js:214:7)
	at ge (/home/rixzz/.vscode/extensions/liximomo.sftp-1.7.6-debug.1/dist/extension.js:70:221943)
	at Ee._transform (/home/rixzz/.vscode/extensions/liximomo.sftp-1.7.6-debug.1/dist/extension.js:70:239716)
	at Ee.Transform._read (_stream_transform.js:186:10)
	at Ee._read (/home/rixzz/.vscode/extensions/liximomo.sftp-1.7.6-debug.1/dist/extension.js:70:233841)
	at Ee.Transform._write (_stream_transform.js:174:12)
	at doWrite (_stream_writable.js:387:12)
	at writeOrBuffer (_stream_writable.js:373:5)
	at Ee.Writable.write (_stream_writable.js:290:11)
	at Socket.ondata (_stream_readable.js:639:20)
	at emitOne (events.js:116:13)
	at Socket.emit (events.js:211:7)
	at addChunk (_stream_readable.js:263:12)
	at readableAddChunk (_stream_readable.js:250:11)
	at Socket.Readable.push (_stream_readable.js:208:10)
	at TCP.onread (net.js:594:20) 

Now the hostname is correctly picked. The weird thing now is that authentication fails because the server is receiving the auth with the user 'rpi' instead of just 'pi':

Nov 16 07:23:47 local sshd[15586]: Invalid user rpi from XXX.XXX.XXX.XXX port 37342
Nov 16 07:23:47 local sshd[15586]: input_userauth_request: invalid user rpi [preauth]
Nov 16 07:23:47 local sshd[15586]: Received disconnect from XXX.XXX.XXX.XXX port 37342:11:  [preauth]
Nov 16 07:23:47 local sshd[15586]: Disconnected from XXX.XXX.XXX.XXX port 37342 [preauth]

@liximomo
Copy link
Owner

liximomo commented Nov 16, 2018

image

The sftp.json takes higher priority.

@RixzZ
Copy link
Author

RixzZ commented Nov 16, 2018

Ups, sorry for that one. Now is working. Thanks!

Do you know when the fix will be available in the release version?

@liximomo
Copy link
Owner

V1.7.6 is released.

@ptaszek1
Copy link

ptaszek1 commented Nov 22, 2018

After that update , i can't connect to ssh :/

[warn] ENOENT: no such file or directory, open 'C:\Users\m.ssh\config' load C:\Users\m.ssh\config failed

@liximomo
Copy link
Owner

@ptaszek1 Please file a new issue.

@ooking
Copy link

ooking commented Feb 21, 2019

After that update , i can't connect to ssh :/

[warn] ENOENT: no such file or directory, open 'C:\Users\m.ssh\config' load C:\Users\m.ssh\config failed

i have the same issue:
[error] Error: Config Not Found. (output:extension-output-%232)
at Object.u [as handleCtxFromUri] (/Users/King/.vscode/extensions/liximomo.sftp-1.9.3/dist/extension.js:1:41646)
at module.exports.t.createFileCommand. (/Users/King/.vscode/extensions/liximomo.sftp-1.9.3/dist/extension.js:1:4045)
at Generator.next ()
at module.exports.r (/Users/King/.vscode/extensions/liximomo.sftp-1.9.3/dist/extension.js:1:3325)
at new Promise ()
at module.exports.r (/Users/King/.vscode/extensions/liximomo.sftp-1.9.3/dist/extension.js:1:3102)
at module.exports.t.createFileCommand.doCommandRun.a.map.t (/Users/King/.vscode/extensions/liximomo.sftp-1.9.3/dist/extension.js:1:3987)
at Array.map ()
at module.exports.t.createFileCommand. (/Users/King/.vscode/extensions/liximomo.sftp-1.9.3/dist/extension.js:1:3980)
at Generator.next ()
at s (/Users/King/.vscode/extensions/liximomo.sftp-1.9.3/dist/extension.js:1:3158)

@steff700
Copy link

Same issue.
One PC works, the another one not. Two fresh installations. VSC 1.31.1, SFTP 1.93

[warn] ENOENT: no such file or directory, open 'C:\Users\NAME.ssh\config' load C:\Users\NAME.ssh\config failed
[error] Error: Config Not Found. (file://nashome/Web/pathto/websites/path/blabla.php)
at Object.u [as handleCtxFromUri] (C:\Users\NAME.vscode\extensions\liximomo.sftp-1.9.3\dist\extension.js:1:41646)
......
The sftp-connection works, but not the upload/download....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants