GithubHelp home page GithubHelp logo

Comments (16)

johnnyman727 avatar johnnyman727 commented on September 18, 2024

@dalestone This is actually an issue with the t2-cli key generation not being compatible with Windows. It uses the ssh-keygen library which is just a wrapper around the ssh-keygen command line utility which Windows doesn't support. We'll need to figure out how to extend key generation support to Windows - do you know of any good SSH libraries?

from t2-vm.

dalestone avatar dalestone commented on September 18, 2024

@johnnyman727 Ah I see that explains why! There is SharpSSH

from t2-vm.

ondreian avatar ondreian commented on September 18, 2024

@johnnyman727

if you allowed your install of Git to enhance your %PATH% with unix tools this shouldn't be a problem.
Linux Tools
For instance on my system, after installing Git with its built in enhancers, ssh-keygen is available at the following location:

C:\Program Files (x86)\Git\bin\ssh-keygen.EXE

You could do a warn about it with insurePath and then not have to support a second type of SSH library perhaps?

from t2-vm.

LinusU avatar LinusU commented on September 18, 2024

I'm trying to fix this here: ericvicenti/ssh-keygen#5

I would love it if you could help me try it out since I don't have access to windows.

If you could change the dependency in t2-cli from "ssh-keygen": "^0.2.1" to "ssh-keygen": "LinusU/ssh-keygen#windows-support" and try it again :)

from t2-vm.

dalestone avatar dalestone commented on September 18, 2024

@ondreian Yep I can confirm if I runt2 key generate in the directory C:\Program Files (x86)\Git\bin\ it works OK!

cmd

@LinusU Sure I will try it, I first need to remove the key its just generated though, how do I do that?

from t2-vm.

johnnyman727 avatar johnnyman727 commented on September 18, 2024

@dalestone I didn't get around to writing the t2 key remove command yet 😛

You can manually rm -rf ~/.tessel/id_rsa*

from t2-vm.

dalestone avatar dalestone commented on September 18, 2024

@johnnyman727 Thanks that removed it. 👍

@LinusU No luck so far! 😢. I changed the package.json and did a npm installl. I have had a look at your source code it seems to be looking in this directory t2-cli\node_modules\ssh-keygen\src\bin\ssh-keygen-64.exe but the files are actually in t2-cli\node_modules\ssh-keygen\bin\ssh-keygen-64.exe.

INFO Creating public and private keys for Tessel authentication...
events.js:85
      throw er; // Unhandled 'error' event
            ^
Error: spawn C:\development\learning\tessel\t2-cli\node_modules\ssh-keygen\src\bin\ssh-keygen-64.exe ENOENT
    at exports._errnoException (util.js:746:11)
    at Process.ChildProcess._handle.onexit (child_process.js:1053:32)
    at child_process.js:1144:20
    at process._tickCallback (node.js:355:11)

So I created the directory it was looking for and copied the *.exe over but then got this error:

PS C:\development\learning\tessel\t2-cli> t2 key generate
INFO Creating public and private keys for Tessel authentication...
C:\development\learning\tessel\t2-cli\lib\tessel\provision.js:61
      var privateKey = out.key;
                          ^
TypeError: Cannot read property 'key' of undefined
    at C:\development\learning\tessel\t2-cli\lib\tessel\provision.js:61:27
    at C:\development\learning\tessel\t2-cli\node_modules\ssh-keygen\src\ssh-keygen.js:81:22
    at FSReqWrap.oncomplete (fs.js:95:15)

from t2-vm.

LinusU avatar LinusU commented on September 18, 2024

@dalestone Fixed the first error, taking a look at the second one now...

from t2-vm.

LinusU avatar LinusU commented on September 18, 2024

@dalestone There is a bug in t2-cli which prevents you from seeing the error that actually happens, could you try with this patch applied? tessel/t2-cli#206

from t2-vm.

dalestone avatar dalestone commented on September 18, 2024

@LinusU Ah OK, I have added your provision.js update but it seems to just print out line 1 and no key gets generated, so I added another logs.info to see what was in err and it seems to be looking for id_rsa but it doesn't exist in the directory

PS C:\development\learning\tessel\t2-cli> t2 key generate
1. INFO Creating public and private keys for Tessel authentication...
2. INFO { [Error: ENOENT, unlink 'C:\Users\Dale\AppData\Local\Temp\id_rsa']
  errno: -4058,
  code: 'ENOENT',
  path: 'C:\\Users\\Dale\\AppData\\Local\\Temp\\id_rsa' }

from t2-vm.

LinusU avatar LinusU commented on September 18, 2024

I hate to ask you to do the debugging for me when we really should have better error handling and logging in place but here goes. If you could log err.stack that would give me where the error is occurring and then I will try and solve it for you :)

Also, my patch got merged so you can just use t2-cli from the master branch.

from t2-vm.

dalestone avatar dalestone commented on September 18, 2024

@LinusU No problem its fun to look at the code 👍. I added err.stack but it doesn't mention any line numbers and gives a rather vague error, unless I have added the logs.info in a bad place?

...
    logs.info('Creating public and private keys for Tessel authentication...');
    // Generate SSH key
    keygen({}, function(err, out) {

      logs.info(err.stack);

      if (err) {
        return reject(err);
      }
...

Error returned:

PS C:\development\learning\tessel\t2-cli> t2 key generate
INFO Creating public and private keys for Tessel authentication...
INFO Error: ENOENT, unlink 'C:\Users\Dale\AppData\Local\Temp\id_rsa'
    at Error (native)

from t2-vm.

LinusU avatar LinusU commented on September 18, 2024

Sorry for the late reply, I got stuck inside the spaghetti code and realized that this is the wrong way to solve this. We shouldn't depend on a third party library to ship up to date binaries when it comes to cryptography.

Instead we should the version of openssl that Node.js provides for us, and that is exactly what I have done in tessel/t2-cli#209. Unfortunately this doesn't work on windows until nodejs/node-v0.x-archive#4051 gets resolved.

If you have any experience with compiling it would be really cool if you could take a look at LinusU/node-generate-rsa-keypair to see if you can get it to build on windows. It could work by installing openssl locally and pointing out the path to it, but ideally we really would like to link against the openssl that node provides for us. That way we will always stay in sync with them.

from t2-vm.

johnnyman727 avatar johnnyman727 commented on September 18, 2024

I should dig out my Windows computer for this...

@LinusU I applaud your library! Would love to get this working.

from t2-vm.

dalestone avatar dalestone commented on September 18, 2024

@LinusU I gave it a try but when I build in visual studio I get a lot of link errors.

Error   8   error LNK1120: 7 unresolved externals   C:\development\learning\tessel\node-generate-rsa-keypair\build\Debug\generate-rsa-keypair.node  generate-rsa-keypair
Error   3   error LNK2019: unresolved external symbol BIO_ctrl referenced in function "void __cdecl generate_rsa_keypair(class v8::FunctionCallbackInfo<class v8::Value> const &)" (?generate_rsa_keypair@@YAXAEBV?$FunctionCallbackInfo@VValue@v8@@@v8@@@Z)    C:\development\learning\tessel\node-generate-rsa-keypair\build\binding.obj  generate-rsa-keypair
Error   1   error LNK2019: unresolved external symbol BIO_new referenced in function "void __cdecl generate_rsa_keypair(class v8::FunctionCallbackInfo<class v8::Value> const &)" (?generate_rsa_keypair@@YAXAEBV?$FunctionCallbackInfo@VValue@v8@@@v8@@@Z) C:\development\learning\tessel\node-generate-rsa-keypair\build\binding.obj  generate-rsa-keypair
Error   4   error LNK2019: unresolved external symbol BIO_s_mem referenced in function "void __cdecl generate_rsa_keypair(class v8::FunctionCallbackInfo<class v8::Value> const &)" (?generate_rsa_keypair@@YAXAEBV?$FunctionCallbackInfo@VValue@v8@@@v8@@@Z)   C:\development\learning\tessel\node-generate-rsa-keypair\build\binding.obj  generate-rsa-keypair
Error   2   error LNK2019: unresolved external symbol BIO_vfree referenced in function "void __cdecl generate_rsa_keypair(class v8::FunctionCallbackInfo<class v8::Value> const &)" (?generate_rsa_keypair@@YAXAEBV?$FunctionCallbackInfo@VValue@v8@@@v8@@@Z)   C:\development\learning\tessel\node-generate-rsa-keypair\build\binding.obj  generate-rsa-keypair
Error   7   error LNK2019: unresolved external symbol PEM_write_bio_RSA_PUBKEY referenced in function "void __cdecl generate_rsa_keypair(class v8::FunctionCallbackInfo<class v8::Value> const &)" (?generate_rsa_keypair@@YAXAEBV?$FunctionCallbackInfo@VValue@v8@@@v8@@@Z)    C:\development\learning\tessel\node-generate-rsa-keypair\build\binding.obj  generate-rsa-keypair
Error   6   error LNK2019: unresolved external symbol PEM_write_bio_RSAPrivateKey referenced in function "void __cdecl generate_rsa_keypair(class v8::FunctionCallbackInfo<class v8::Value> const &)" (?generate_rsa_keypair@@YAXAEBV?$FunctionCallbackInfo@VValue@v8@@@v8@@@Z) C:\development\learning\tessel\node-generate-rsa-keypair\build\binding.obj  generate-rsa-keypair
Error   5   error LNK2019: unresolved external symbol RSA_generate_key referenced in function "void __cdecl generate_rsa_keypair(class v8::FunctionCallbackInfo<class v8::Value> const &)" (?generate_rsa_keypair@@YAXAEBV?$FunctionCallbackInfo@VValue@v8@@@v8@@@Z)    C:\development\learning\tessel\node-generate-rsa-keypair\build\binding.obj  generate-rsa-keypair

Also running node-gyp build gives pretty much the same:

C:\development\learning\tessel\node-generate-rsa-keypair>node-gyp build
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | win32 | x64
gyp info spawn C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe
gyp info spawn args [ 'build/binding.sln',
gyp info spawn args   '/clp:Verbosity=minimal',
gyp info spawn args   '/nologo',
gyp info spawn args   '/p:Configuration=Release;Platform=x64' ]
Building the projects in this solution one at a time. To enable parallel build,
please add the "/m" switch.
     Creating library C:\development\learning\tessel\node-generate-rsa-keypair\
  build\Release\generate-rsa-keypair.lib and object C:\development\learning\tes
  sel\node-generate-rsa-keypair\build\Release\generate-rsa-keypair.exp
binding.obj : error LNK2001: unresolved external symbol RSA_generate_key [C:\de
velopment\learning\tessel\node-generate-rsa-keypair\build\generate-rsa-keypair.
vcxproj]
binding.obj : error LNK2001: unresolved external symbol PEM_write_bio_RSA_PUBKE
Y [C:\development\learning\tessel\node-generate-rsa-keypair\build\generate-rsa-
keypair.vcxproj]
binding.obj : error LNK2001: unresolved external symbol BIO_new [C:\development
\learning\tessel\node-generate-rsa-keypair\build\generate-rsa-keypair.vcxproj]
binding.obj : error LNK2001: unresolved external symbol BIO_ctrl [C:\developmen
t\learning\tessel\node-generate-rsa-keypair\build\generate-rsa-keypair.vcxproj]
binding.obj : error LNK2001: unresolved external symbol BIO_s_mem [C:\developme
nt\learning\tessel\node-generate-rsa-keypair\build\generate-rsa-keypair.vcxproj
]
binding.obj : error LNK2001: unresolved external symbol PEM_write_bio_RSAPrivat
eKey [C:\development\learning\tessel\node-generate-rsa-keypair\build\generate-r
sa-keypair.vcxproj]
binding.obj : error LNK2001: unresolved external symbol BIO_vfree [C:\developme
nt\learning\tessel\node-generate-rsa-keypair\build\generate-rsa-keypair.vcxproj
]
C:\development\learning\tessel\node-generate-rsa-keypair\build\Release\generate
-rsa-keypair.node : fatal error LNK1120: 7 unresolved externals [C:\development
\learning\tessel\node-generate-rsa-keypair\build\generate-rsa-keypair.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` fail
ed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Users\Dale\AppData\Roaming\npm\nod
e_modules\node-gyp\lib\build.js:269:23)
gyp ERR! stack     at ChildProcess.emit (events.js:110:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1074
:12)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "node" "C:\\Users\\Dale\\AppData\\Roaming\\npm\\node_modules\\n
ode-gyp\\bin\\node-gyp.js" "build"
gyp ERR! cwd C:\development\learning\tessel\node-generate-rsa-keypair
gyp ERR! node -v v0.12.3
gyp ERR! node-gyp -v v2.0.2
gyp ERR! not ok

from t2-vm.

LinusU avatar LinusU commented on September 18, 2024

Hmm, yes the link errors must be because of nodejs/node-v0.x-archive#4051. It makes it so that openssl dosen't export any functions at all, which makes the linker fail to find them...

from t2-vm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.