trustcrypto/onlykey-agent

Does not work on Windows 10

Opened this issue · 4 comments

Installed with pip bundled with Python choco package

C:\Users\user>onlykey-agent -vvv -c root@192.168.12.145
Traceback (most recent call last):
  File "C:\Python38\Scripts\onlykey-agent-script.py", line 11, in <module>
    load_entry_point('onlykey-agent==0.0.4', 'console_scripts', 'onlykey-agent')()
  File "c:\python38\lib\site-packages\pkg_resources\__init__.py", line 489, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "c:\python38\lib\site-packages\pkg_resources\__init__.py", line 2852, in load_entry_point
    return ep.load()
  File "c:\python38\lib\site-packages\pkg_resources\__init__.py", line 2443, in load
    return self.resolve()
  File "c:\python38\lib\site-packages\pkg_resources\__init__.py", line 2449, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "c:\python38\lib\site-packages\onlykey_agent\__main__.py", line 10, in <module>
    from . import client, formats, protocol, server
  File "c:\python38\lib\site-packages\onlykey_agent\client.py", line 49
    print 'identity', identity
          ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print('identity', identity)?

@alien2003 Yes, SSH works differently on Windows, up until recently Windows didn't even support SSH on command line at all and you had to use a tool like Putty. The agent should work if you use WSL - https://docs.microsoft.com/en-us/windows/wsl/install-win10

Edit - I just noticed the error also indicates you are using python 3 and the onlykey-agent is python 2.

Windows has OpenSSH client and server now. I can just type ssh root@server in CMD and connect.
With Python 2.7

C:\Users\user>onlykey-agent -vvv -c root@192.168.12.145
2019-10-23 19:19:04,687 DEBUG        connected                                                                                            [client.py:160]
Traceback (most recent call last):
  File "c:\python27\lib\runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "c:\python27\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:\Python27\Scripts\onlykey-agent.exe\__main__.py", line 7, in <module>
  File "c:\python27\lib\site-packages\onlykey_agent\__main__.py", line 123, in wrapper
    return func(*args, **kwargs)
  File "c:\python27\lib\site-packages\onlykey_agent\__main__.py", line 136, in run_agent
    with client_factory(curve=args.ecdsa_curve_name) as conn:
  File "c:\python27\lib\site-packages\onlykey_agent\client.py", line 33, in __enter__
    self.ok.read_string(timeout_ms=50)
  File "c:\python27\lib\site-packages\onlykey\client.py", line 355, in read_string
    return ''.join([chr(item) for item in self.read_bytes(MAX_INPUT_REPORT_SIZE, timeout_ms=timeout_ms) if item != 0])
  File "c:\python27\lib\site-packages\onlykey\client.py", line 344, in read_bytes
    out = self._hid.read(n, timeout_ms=timeout_ms)
  File "hid.pyx", line 105, in hid.device.read
ValueError: not open

Not a critical bug because I mostly use GNU/Linux, but would be great to implement native Windows support without WSL

Hi, I am having exactly the same issue alien2003 has mentioned, even though I am using WSL. Tried on both Debian and Ubuntu 18.04 LTS "apps". Went through the installation, have setup the UDEV rule, on both cases I am getting the "ValueError: not open" error.

xxxx@xxxxx:~$ onlykey-agent -c xxxx@xxxxx.net -vvv
2020-03-04 11:13:20,934 DEBUG        connected                                                                                            [client.py:160]
Traceback (most recent call last):
  File "/usr/local/bin/onlykey-agent", line 11, in <module>
    sys.exit(run_agent())
  File "/usr/local/lib/python2.7/dist-packages/onlykey_agent/__main__.py", line 123, in wrapper
    return func(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/onlykey_agent/__main__.py", line 136, in run_agent
    with client_factory(curve=args.ecdsa_curve_name) as conn:
  File "/usr/local/lib/python2.7/dist-packages/onlykey_agent/client.py", line 33, in __enter__
    self.ok.read_string(timeout_ms=50)
  File "/usr/local/lib/python2.7/dist-packages/onlykey/client.py", line 355, in read_string
    return ''.join([chr(item) for item in self.read_bytes(MAX_INPUT_REPORT_SIZE, timeout_ms=timeout_ms) if item != 0])
  File "/usr/local/lib/python2.7/dist-packages/onlykey/client.py", line 344, in read_bytes
    out = self._hid.read(n, timeout_ms=timeout_ms)
  File "hid.pyx", line 106, in hid.device.read
ValueError: not open

It should be noted this is the first time (and hopefully the last time) I am using WSL in my life. I might be doing something wrong - I've spent most of the morning trying to figure out what. This works well for me both on linux & mac. I am testing it on windows because I would like to introduce these into my company...

@CargoCoder We have not tested this with WSL. I expect it will work as long as WSL allows the USB HID messages from host to WSL. I would try the following:

  1. In Win10 verify that the OnlyKey app works (USB HID communication with host OK)
  2. In WSL see that USB device shows up with $ lsusb (USB hardware connected)
  3. In WSL see that OnlyKey is connected using the OnlyKey CLI app here - https://docs.crp.to/command-line.html
  4. If that works the onlykey-agent should work, if not udev rule may be needed - https://docs.crp.to/linux.html