mscdex/ssh2 unable to connect to pageant.

Max Korp's Avatar

Max Korp

05 Jun, 2015 09:49 PM

Hi, I'm trying to use a tool for deployment in a private project that relies underneath ssh2 (https://github.com/mscdex/ssh2). I'm trying to connect via pageant (It doesnt appear you have a cygwin socket running, so that seems like the natural way to go about it). I know we can run and connect in other ways via pageant, because we use it for connections in some tests in the nodegit/nodegit project. The relevant part of the appveyor.yml looks like this
```yml on_success:
- ps: Start-Process c:\projects\ThisProject\vendor\pageant.exe c:\projects\ThisProject\vendor\private.ppk - ps: script\doOurDeploymentPreparation

In there, we have ssh2 set to hook up to pageant. It connects using pageant by calling a small executable that's bundled with it, the source of which can be seen here: https://github.com/mscdex/ssh2/blob/master/util/pagent.c


the call to the executable is returning an error 11 (RET_ERR_UNAVAILABLE). This is only returned from one spot in the application. Skipping the rest of the code you can see below it makes a call to windows.h's FindWindow, which isn't finding pageant running.

#include <windows.h>
#include <stdio.h>
#include <fcntl.h>

#define RET_ERR_UNAVAILABLE 11
int main (int argc, const char* argv[]) {
  HWND hwnd;
  hwnd = FindWindow("Pageant", "Pageant");
  if (!hwnd)
    return RET_ERR_UNAVAILABLE;
}</code>
</pre>

`FindWindow("Pageant", Pageant");` Seems to be the globally accepted way of finding pageant, but in our case it's not finding anything. I'm assuming this is in some way related to the powershell script `Start-Process`. Any ideas on how to get this up and running?

  1. 1 Posted by Max Korp on 05 Jun, 2015 09:54 PM

    Max Korp's Avatar

    Hrm, Markdown support seems a bit touchy... Reposting without formatting.

    Relevant part of appveyor.yml
    on_success:
     - ps: Start-Process c:\projects\ThisProject\vendor\pageant.exe c:\projects\ThisProject\vendor\private.ppk
     - ps: script\doOurDeploymentPreparation

    In that script, we have ssh2 set to hook up to pageant. It connects using pageant by calling a small executable that's bundled with it, the source of which can be seen here: https://github.com/mscdex/ssh2/blob/master/util/pagent.c

    the call to the executable is returning an error 11 (RET_ERR_UNAVAILABLE). This is only returned from one spot in the application. Skipping the rest of the code you can see below it makes a call to windows.h's FindWindow, which isn't finding pageant running.

    #include <windows.h>
    #include <stdio.h>
    #include <fcntl.h>

    #define RET_ERR_UNAVAILABLE 11

    int main (int argc, const char* argv[]) {
      HWND hwnd;

      hwnd = FindWindow("Pageant", "Pageant");
      if (!hwnd)
        return RET_ERR_UNAVAILABLE;

      // do stuff
    }

    `FindWindow("Pageant", Pageant");` Seems to be the globally accepted way of finding pageant, but in our case it's not finding anything. I'm assuming this is in some way related to the powershell script `Start-Process`. Any ideas on how to get this up and running?

  2. Support Staff 2 Posted by Feodor Fitsner on 05 Jun, 2015 10:21 PM

    Feodor Fitsner's Avatar

    Is the build running on Pro environment?

    - Feodor

  3. 3 Posted by Max Korp on 05 Jun, 2015 10:43 PM

    Max Korp's Avatar

    Yes, Axosoft/Gitkraken.

    It's looking a little wild right now, (I've got pageant starting in a few places to see if it was getting terminated or sandboxed by start-process) but it's there. I'll tidy it back up.

  4. 4 Posted by Max Korp on 05 Jun, 2015 11:04 PM

    Max Korp's Avatar

    Whoops, I guess it's Gitkraken/gitkraken.

  5. Support Staff 5 Posted by Feodor Fitsner on 06 Jun, 2015 05:04 AM

    Feodor Fitsner's Avatar

    Have you tried looking into build VM via RDP to see what's going on? https://github.com/appveyor/ci/blob/master/scripts/enable-rdp.ps1

    There is a number of ways to run child process, maybe Start-Process is not suitable for this case. Try using Process class with UseShellExecute or without.

  6. 6 Posted by Max Korp on 07 Jun, 2015 06:44 PM

    Max Korp's Avatar

    Interesting, I'll take a looka t using RDP. I can try using Process class if it comes down to it, although that's adding more code that might not be needed.

    What type of key is the ssh key that shows in the repo settings? (There is listed only a public key and fingerprint). Is that accessible somewhere in the VM? If it's a standard openSSH type key, The code I have running can parse it and read it directly.

    I tried putting the conetents of an ssh key in the encrypt tool and writing that to file during build, but I suspect it's getting mangled a bit (probably line endings or such).

  7. 7 Posted by Max Korp on 07 Jun, 2015 07:15 PM

    Max Korp's Avatar

    Ah, so the line endings issue was actually it all along. It was preventing putty from starting properly, since the PPK file being written out was malformed.

    I'll make a feature request for file encryptions. Being able to RDP in fixed it. Thanks a ton!

  8. Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 01:56 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac