Onlykey-agent MacOS Illegal Instruction

Hi all

I’m having issues with onlykey-agent on MacOS (x86 Monterey 12.5.1). On exit, there is always an error message: “Illegal Instruction: 4”, at which point the OS pops up a message saying Python died. Has anyone come across this, and/or know a way to fix it?

I’d really like to be able to use my OnlyKey for SSH auth, but this is stopping it being practical at the moment (particularly, running it in the background with all keys available)

Thanks in advance

Are you installing OnlyKey agent with “brew install onlykey-agent”?

Yes. I’ve also tried removing and reinstalling a load of dependencies, as well as telling brew to build from source for both python and libusb, with no success.

We just recently updated the Mac instructions to use brew, I am not sure what the issue is here but alternatively you can use the old method which is to use pip.

pip3 install onlykey-agent

Unfortunately this brings the same problem.

MAC0000:ok-helpers #######$ onlykey-agent ~/.ssh/github.pub -- git clone git@github.com:company/repo.git
Cloning into 'repo'...
Enter the 3 digit challenge code on OnlyKey to authorize <ssh://git@github.com|ed25519>
1 4 2
remote: Enumerating objects: 5857, done.
remote: Counting objects: 100% (1506/1506), done.
remote: Compressing objects: 100% (708/708), done.
remote: Total 5857 (delta 869), reused 1344 (delta 756), pack-reused 4351
Receiving objects: 100% (5857/5857), 802.95 KiB | 1.67 MiB/s, done.
Resolving deltas: 100% (3539/3539), done.
Illegal instruction: 4

Note, in this case the clone does complete successfully, but onlykey-agent bombs as it’s exiting. This also means running it as a “daemon” doesn’t work either, as it bombs shortly after first “use”.

A bit of research suggests this error occurs when something has been compiled incorrectly for the architecture on which it’s running (hence why I tried rebuilding stuff from source). I have no idea why that would be happening… This is the first time I’ve some across this, and it’s not exactly an outdated machine (2019).

@karlw-bjss Can you run the command with “-vvv” so we can see verbose output? That might show where the error is occurring.

$ onlykey-agent -vvv ~/.ssh/github.pub -- git clone git@github.com:company/repo.git
2022-08-25 16:13:34,833 DEBUG        Setting skey slot = 132                                                                              [onlykey.py:58]
2022-08-25 16:13:34,834 DEBUG        loading SSH public key: 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICXUmA3VaORpSNaRf4PWsiar228DdwnA9nyyo33RQv5K <ssh://git@github.com|ed25519>\n' [formats.py:260]
2022-08-25 16:13:34,834 DEBUG        key type: b'ssh-ed25519'                                                                             [formats.py:68]
2022-08-25 16:13:34,834 DEBUG        loaded ssh-ed25519 public key: 8f:00:b4:21:65:07:6b:6e:9b:b1:58:e4:d3:ca:25:58                       [formats.py:266]
2022-08-25 16:13:34,834 DEBUG        parsed identity: {'proto': 'ssh', 'user': 'git', 'host': 'github.com', 'port': None, 'path': None}   [interface.py:30]
2022-08-25 16:13:34,834 DEBUG        identity parts: ['ssh://', 'git@', 'github.com']                                                     [interface.py:46]
2022-08-25 16:13:34,834 INFO         identity #0: <ssh://git@github.com|ed25519>                                                          [__init__.py:287]
2022-08-25 16:13:34,843 DEBUG        local SSH version: b'OpenSSH_8.6p1, LibreSSL 3.3.6\n'                                                [__init__.py:144]
2022-08-25 16:13:34,844 DEBUG        serving on /var/folders/r3/9klk0jqd49d5rx1s_hf28n0x0d6_f8/T/trezor-ssh-agent-nqkzkx_p                [server.py:30]
2022-08-25 16:13:34,845 DEBUG        server thread started                                                                                [server.py:121]
2022-08-25 16:13:34,845 DEBUG        waiting for connection on /var/folders/r3/9klk0jqd49d5rx1s_hf28n0x0d6_f8/T/trezor-ssh-agent-nqkzkx_p [server.py:129]
2022-08-25 16:13:34,845 INFO         running ['git', 'clone', 'git@github.com:company/repo.git'] with {'SSH_AUTH_SOCK': '/var/folders/r3/9klk0jqd49d5rx1s_hf28n0x0d6_f8/T/trezor-ssh-agent-nqkzkx_p', 'SSH_AGENT_PID': '9733'} [server.py:156]
2022-08-25 16:13:34,848 DEBUG        subprocess 9735 is running                                                                           [server.py:163]
Cloning into 'repo'...
2022-08-25 16:13:35,446 DEBUG        welcome agent                                                                                        [server.py:90]
2022-08-25 16:13:35,446 DEBUG        request: 1 bytes                                                                                     [protocol.py:97]
2022-08-25 16:13:35,446 DEBUG        calling list_pubs()                                                                                  [protocol.py:105]
2022-08-25 16:13:35,446 DEBUG        loading SSH public key: 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICXUmA3VaORpSNaRf4PWsiar228DdwnA9nyyo33RQv5K <ssh://git@github.com|ed25519>\n' [formats.py:260]
2022-08-25 16:13:35,446 DEBUG        key type: b'ssh-ed25519'                                                                             [formats.py:68]
2022-08-25 16:13:35,446 DEBUG        loaded ssh-ed25519 public key: 8f:00:b4:21:65:07:6b:6e:9b:b1:58:e4:d3:ca:25:58                       [formats.py:266]
2022-08-25 16:13:35,446 DEBUG        available keys: [b'<ssh://git@github.com|ed25519>']                                                  [protocol.py:117]
2022-08-25 16:13:35,446 DEBUG         1) 8f:00:b4:21:65:07:6b:6e:9b:b1:58:e4:d3:ca:25:58                                                  [protocol.py:119]
2022-08-25 16:13:35,447 DEBUG        reply: 98 bytes                                                                                      [protocol.py:108]
2022-08-25 16:13:35,447 DEBUG        waiting for connection on /var/folders/r3/9klk0jqd49d5rx1s_hf28n0x0d6_f8/T/trezor-ssh-agent-nqkzkx_p [server.py:129]
2022-08-25 16:13:36,071 DEBUG        request: 210 bytes                                                                                   [protocol.py:97]
2022-08-25 16:13:36,071 DEBUG        calling sign_message()                                                                               [protocol.py:105]
2022-08-25 16:13:36,071 DEBUG        key type: b'ssh-ed25519'                                                                             [formats.py:68]
2022-08-25 16:13:36,072 DEBUG        looking for 8f:00:b4:21:65:07:6b:6e:9b:b1:58:e4:d3:ca:25:58                                          [protocol.py:131]
2022-08-25 16:13:36,072 DEBUG        loading SSH public key: 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICXUmA3VaORpSNaRf4PWsiar228DdwnA9nyyo33RQv5K <ssh://git@github.com|ed25519>\n' [formats.py:260]
2022-08-25 16:13:36,072 DEBUG        key type: b'ssh-ed25519'                                                                             [formats.py:68]
2022-08-25 16:13:36,072 DEBUG        loaded ssh-ed25519 public key: 8f:00:b4:21:65:07:6b:6e:9b:b1:58:e4:d3:ca:25:58                       [formats.py:266]
2022-08-25 16:13:36,072 DEBUG        using key b'<ssh://git@github.com|ed25519>' (8f:00:b4:21:65:07:6b:6e:9b:b1:58:e4:d3:ca:25:58)        [protocol.py:139]
2022-08-25 16:13:36,072 DEBUG        signing 146-byte blob with "<ssh://git@github.com|ed25519>" key                                      [protocol.py:146]
2022-08-25 16:13:36,072 DEBUG        blob: b'\x00\x00\x00 \x8f3u\xd9\x0e(\xfe%\xfd7\x9a\x06\x07c\x82<\xcd\x87\xc8\xce\xbe\x03\xea\x12P\xf2\x89\xb3\x9d\x0e\xbb\xd32\x00\x00\x00\x03git\x00\x00\x00\x0essh-connection\x00\x00\x00\tpublickey\x01\x00\x00\x00\x0bssh-ed25519\x00\x00\x003\x00\x00\x00\x0bssh-ed25519\x00\x00\x00 %\xd4\x98\r\xd5h\xe4iH\xd6\x91\x7f\x83\xd6\xb2&\xab\xdbo\x03w\t\xc0\xf6|\xb2\xa3}\xd1B\xfeJ' [client.py:34]
2022-08-25 16:13:36,072 DEBUG        key type: b'ssh-ed25519'                                                                             [formats.py:68]
2022-08-25 16:13:36,073 DEBUG        b'ssh-connection': user b'git' via b'publickey' (b'ssh-ed25519')                                     [client.py:40]
2022-08-25 16:13:36,073 DEBUG        nonce: b'\x8f3u\xd9\x0e(\xfe%\xfd7\x9a\x06\x07c\x82<\xcd\x87\xc8\xce\xbe\x03\xea\x12P\xf2\x89\xb3\x9d\x0e\xbb\xd3' [client.py:42]
2022-08-25 16:13:36,073 DEBUG        fingerprint: 8f:00:b4:21:65:07:6b:6e:9b:b1:58:e4:d3:ca:25:58                                         [client.py:44]
2022-08-25 16:13:36,073 DEBUG        hidden challenge size: 146 bytes                                                                     [client.py:45]
2022-08-25 16:13:36,073 DEBUG        identity parts: ['ssh://', 'git@', 'github.com']                                                     [interface.py:46]
2022-08-25 16:13:36,073 INFO         please confirm user "git" login to "<ssh://git@github.com|ed25519>" using OnlyKey...                 [client.py:47]
2022-08-25 16:13:36,204 DEBUG        connected                                                                                            [client.py:246]
2022-08-25 16:13:36,204 DEBUG        preparing payload for writing                                                                        [client.py:298]
2022-08-25 16:13:36,204 DEBUG        msg=OKSETTIME                                                                                        [client.py:304]
2022-08-25 16:13:36,204 DEBUG        payload=[99, 7, 145, 160]                                                                            [client.py:328]
2022-08-25 16:13:36,204 DEBUG        sending message                                                                                      [client.py:341]
2022-08-25 16:13:36,223 DEBUG        read="UNLOCKEDv2.1.2-prodc"                              [client.py:398]
2022-08-25 16:13:36,223 DEBUG        outstring="bytearray(b'UNLOCKEDv2.1.2-prodc\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')" [client.py:400]
2022-08-25 16:13:36,223 DEBUG        identity parts: ['ssh://', 'git@', 'github.com']                                                     [interface.py:46]
2022-08-25 16:13:36,223 DEBUG        "<ssh://git@github.com|ed25519>" signing b'\x00\x00\x00 \x8f3u\xd9\x0e(\xfe%\xfd7\x9a\x06\x07c\x82<\xcd\x87\xc8\xce\xbe\x03\xea\x12P\xf2\x89\xb3\x9d\x0e\xbb\xd32\x00\x00\x00\x03git\x00\x00\x00\x0essh-connection\x00\x00\x00\tpublickey\x01\x00\x00\x00\x0bssh-ed25519\x00\x00\x003\x00\x00\x00\x0bssh-ed25519\x00\x00\x00 %\xd4\x98\r\xd5h\xe4iH\xd6\x91\x7f\x83\xd6\xb2&\xab\xdbo\x03w\t\xc0\xf6|\xb2\xa3}\xd1B\xfeJ' (ed25519) on OnlyKey [onlykey.py:248]
2022-08-25 16:13:36,225 INFO         Identity to hash =b'git@github.com'                                                                  [onlykey.py:280]
2022-08-25 16:13:36,225 INFO         Identity hash =b'=\xe12\xcd\x98\xbe{\xf2ko\x08\xe8\x1c1\xc7\x99\xa8\x91\xbc2\x04ka\xf0\xb6\xfe6q\xca.D\xb5' [onlykey.py:281]
2022-08-25 16:13:36,225 INFO         Key type ed25519                                                                                     [onlykey.py:288]
2022-08-25 16:13:36,225 INFO         Key Slot =201                                                                                        [onlykey.py:311]
2022-08-25 16:13:36,225 DEBUG        identity parts: ['ssh://', 'git@', 'github.com']                                                     [interface.py:46]
Enter the 3 digit challenge code on OnlyKey to authorize <ssh://git@github.com|ed25519>
2 1 3
2022-08-25 16:13:36,225 DEBUG        preparing payload for writing                                                                        [client.py:298]
2022-08-25 16:13:36,225 DEBUG        msg=OKSIGN                                                                                           [client.py:304]
2022-08-25 16:13:36,225 DEBUG        payload=[201, 255, 0, 0, 0, 32, 143, 51, 117, 217, 14, 40, 254, 37, 253, 55, 154, 6, 7, 99, 130, 60, 205, 135, 200, 206, 190, 3, 234, 18, 80, 242, 137, 179, 157, 14, 187, 211, 50, 0, 0, 0, 3, 103, 105, 116, 0, 0, 0, 14, 115, 115, 104, 45, 99, 111, 110, 110, 101] [client.py:328]
2022-08-25 16:13:36,225 DEBUG        sending message                                                                                      [client.py:341]
2022-08-25 16:13:36,227 DEBUG        preparing payload for writing                                                                        [client.py:298]
2022-08-25 16:13:36,227 DEBUG        msg=OKSIGN                                                                                           [client.py:304]
2022-08-25 16:13:36,227 DEBUG        payload=[201, 255, 99, 116, 105, 111, 110, 0, 0, 0, 9, 112, 117, 98, 108, 105, 99, 107, 101, 121, 1, 0, 0, 0, 11, 115, 115, 104, 45, 101, 100, 50, 53, 53, 49, 57, 0, 0, 0, 51, 0, 0, 0, 11, 115, 115, 104, 45, 101, 100, 50, 53, 53, 49, 57, 0, 0, 0, 32] [client.py:328]
2022-08-25 16:13:36,227 DEBUG        sending message                                                                                      [client.py:341]
2022-08-25 16:13:36,228 DEBUG        preparing payload for writing                                                                        [client.py:298]
2022-08-25 16:13:36,228 DEBUG        msg=OKSIGN                                                                                           [client.py:304]
2022-08-25 16:13:36,228 DEBUG        payload=[201, 255, 37, 212, 152, 13, 213, 104, 228, 105, 72, 214, 145, 127, 131, 214, 178, 38, 171, 219, 111, 3, 119, 9, 192, 246, 124, 178, 163, 125, 209, 66, 254, 74, 61, 225, 50, 205, 152, 190, 123, 242, 107, 111, 8, 232, 28, 49, 199, 153, 168, 145, 188, 50, 4, 107, 97, 240, 182] [client.py:328]
2022-08-25 16:13:36,228 DEBUG        sending message                                                                                      [client.py:341]
2022-08-25 16:13:36,229 DEBUG        preparing payload for writing                                                                        [client.py:298]
2022-08-25 16:13:36,229 DEBUG        msg=OKSIGN                                                                                           [client.py:304]
2022-08-25 16:13:36,229 DEBUG        payload=[201, 7, 254, 54, 113, 202, 46, 68, 181]                                                     [client.py:328]
2022-08-25 16:13:36,229 DEBUG        sending message                                                                                      [client.py:341]
2022-08-25 16:13:36,333 DEBUG        read=""                                                                                              [client.py:398]
2022-08-25 16:13:36,333 DEBUG        outstring="bytearray(b'')"                                                                           .... (Many repeats waiting for challenge)
[client.py:400]
2022-08-25 16:13:42,982 DEBUG        read=""                                                                                              [client.py:398]
2022-08-25 16:13:42,982 DEBUG        outstring="bytearray(b'')"                                                                           [client.py:400]
"                              [client.py:398]3YZÜÚxÜ¥@\行ñTý.Ù“¨¸ÎG¶êxC` bïÝ¡Òé'´¢ªÂÇÌ2—Öê;@{/¢Ì´ß
2022-08-25 16:13:43,056 DEBUG        outstring="bytearray(b"\xdc\xe1?3YZ\xdc\xdax\xdc\xa5@\\\x06\xe8\xa1\x8c\xf1T\xfd.\x8f\xd9\x93\xa8\xb8\xceG\xb6\xeax\x0fC` b\xef\xdd\xa1\xd2\xe9\'\xb4\xa2\xaa\xc2\xc7\xcc\x102\x97\xd6\xea;@\x18\x8f{/\xa2\xcc\xb4\xdf\r")" [client.py:400]
2022-08-25 16:13:43,056 INFO         received= [220, 225, 63, 51, 89, 90, 220, 218, 120, 220, 165, 64, 92, 6, 232, 161, 140, 241, 84, 253, 46, 143, 217, 147, 168, 184, 206, 71, 182, 234, 120, 15, 67, 96, 32, 98, 239, 221, 161, 210, 233, 39, 180, 162, 170, 194, 199, 204, 16, 50, 151, 214, 234, 59, 64, 24, 143, 123, 47, 162, 204, 180, 223, 13] [onlykey.py:327]
2022-08-25 16:13:43,056 INFO         disconnected from OnlyKey                                                                            [onlykey.py:330]
2022-08-25 16:13:43,057 INFO         disconnected from OnlyKey                                                                            [onlykey.py:117]
2022-08-25 16:13:43,057 DEBUG        signature: b"\xdc\xe1?3YZ\xdc\xdax\xdc\xa5@\\\x06\xe8\xa1\x8c\xf1T\xfd.\x8f\xd9\x93\xa8\xb8\xceG\xb6\xeax\x0fC` b\xef\xdd\xa1\xd2\xe9'\xb4\xa2\xaa\xc2\xc7\xcc\x102\x97\xd6\xea;@\x18\x8f{/\xa2\xcc\xb4\xdf\r" [protocol.py:155]
2022-08-25 16:13:43,058 DEBUG        verify signature                                                                                     [formats.py:124]
2022-08-25 16:13:43,058 INFO         signature status: OK                                                                                 [protocol.py:159]
2022-08-25 16:13:43,058 DEBUG        signature size: 64 bytes                                                                             [protocol.py:164]
2022-08-25 16:13:43,058 DEBUG        reply: 92 bytes                                                                                      [protocol.py:108]
2022-08-25 16:13:43,217 DEBUG        goodbye agent                                                                                        [server.py:98]
remote: Enumerating objects: 5859, done.
remote: Counting objects: 100% (5859/5859), done.
remote: Compressing objects: 100% (2062/2062), done.
remote: Total 5859 (delta 3599), reused 5812 (delta 3597), pack-reused 0
Receiving objects: 100% (5859/5859), 772.61 KiB | 1.54 MiB/s, done.
Resolving deltas: 100% (3599/3599), done.
2022-08-25 16:13:44,603 DEBUG        subprocess 9735 exited: 0                                                                            [server.py:165]
2022-08-25 16:13:44,604 DEBUG        closing server                                                                                       [__init__.py:160]
2022-08-25 16:13:44,615 DEBUG        server stopped                                                                                       [server.py:133]
2022-08-25 16:13:44,616 DEBUG        server thread stopped                                                                                [server.py:138]
Illegal instruction: 4

Hi,

I am having the same problem on MacOS with onlykey-agent, is there anything I can do to provide additional information to expedite a solution for this?

regards,

Frederik

This issue in the upstream library can be found here.

A partial solution can be found here.

@Stammer9222 Are you seeing the agent fail or SSH login succeeds and then throws the error? This sounds like the same issue as this onlykey-agent crashes on mac · Issue #38 · trustcrypto/onlykey-agent · GitHub still trying to find a solution seems to be related to HID library

This is the problem I have.
I connect via SSH just fine however when I try and do a git push then the agent crashes randomly