Snowflake-Labs / sqltools-snowflake-driver

A Snowflake driver for the SQLTools VSCode extension.
MIT License
35 stars 15 forks source link

KeyPair on WSL2 (probably WSL too) not working #45

Open anujghai opened 3 years ago

anujghai commented 3 years ago

Got public / private keypair working using snowflake connector for python and snowsql both on WSL2 but having difficulty recognising the private key file via the Snowflake Connecto on SQLTool. I've copied the key file from WSL to /mnt/c to see if that is the problem but the same message with a different directory. In both cases I pick the file from the drop down instead of typing it in directly.

Error log shows as: [1622678960563] ERROR (ls): Connecting error: {"code":-32001,"data":{"driver":"Snowflake","driverOptions":{}},"name":"Error"} ns: "conn-manager" [1622678960565] ERROR (ext): ERROR: Error opening connection ENOENT: no such file or directory, open '\wsl$\Ubuntu\home\itsme\snowflake\snowflake_keys\snowflake_test.rsa_key', {"code":-32001,"data":{"driver":"Snowflake","driverOptions":{}}} ns: "error-handler" [1623272025619] INFO (ext): EXECUTING COMMAND => sqltools.showOutputChannel

anujghai commented 3 years ago

Hi, I got a fix: In short the key full filepath needs to be in Native Linux format as you would get to it from your WSL disstro and do not use the SELECT FILE Button as it will build the path in Windows format.

An enhancement would be if WSL is being used that the file button Select would use the filepath for the Linux distro.

I don't know how to change the status to enhancement. Sorry. Could the owner please change it.

Details: Don't pick the private key from the SELECT FILE button if you are on WSL2. This is because the file path is in Windows format and you need it in Linux format. The egs below are as if I has the key in both Windows and Linux and was to pick one of them. Personally if I'm using wsl I'd leave the key in the wsl distro especilly if you're using the same ksy for sqnowsql or the python connector. eg: BAD
WINDOWS wrong format although it looks okay (If I pick from the SELECT file button) A) Use KEY on Windows dir: C:\itsme\snowflake_test.rsa_key B) Use KEY on Linux dir: \wsl$\Ubuntu\home\itsme\snowflake\snowflake_keys\snowflake_test.rsa_key eg: GOOD
LINUX right format enter it directlyv(eg is with Ubuntu 18.04.03 distro) A) Use KEY on Windows dir: /mnt/c/itsme/snowflake_test.rsa_key B) Use KEY on Linux dir: /home/itsme/snowflake/snowflake_keys/snowflake_test.rsa_key

Dremet commented 2 years ago

Could you show how you configured this? @anujghai