Configuring and generating OTPs from the command line

Are you aware of any tools to configure and generate one-time passwords using the Nitrokey Pro from the command line? I found gkey (forum post), but it is unfortunately inactive and only supports generation of OTPs.

Best,
Robin

Hi Robin!

There is a plan to make a CLI tool using libnitrokey - issue #64. Perhaps you could create an issue on another CLI tool to add support for OTP there - nitrocli (focused on Storage’s volume management).
Indirectly answering - if you know any programming language, that can use C functions (Python, C/C++, D, Go etc.) then you can use that. See NK_C_API.h for C API. We work with it in libnitrokey’s tests. It is possible to run it interactively in IPython3.

Thanks for the pointers! As my Rust skills never left the phase of experimentation, I’d go with implementing as a new standalone program. Would it make sense to somehow combine this with the CLI tool plans you mentioned, or should I just write something on my own?

I have an idea in mind to have the CLI in Python’s PIP package (to have REPL as well). I thought also about integrating some read-only commands to Nitrokey App binary. Both are planned realistically for the second half of the year, therefore it may be better to start a new project or continue one of the mentioned.
For communication layer instead of writing own solution I can recommend libnitrokey for its Python’s tests - these are run on its each release and each firmware release as well.

Okay, I started to code something. I’ll post an update here once I had the chance to actually test it, in case someone else wants to use it too.

2 Likes

Since February, I changed my mind and had another look at Rust. As a part of the command-line tool, I also wrote a “rusty” wrapper around libnitrokey. Is it okay to publish this wrapper under the name nitrokey (for Rust, nitrokey-rs in a non-Rust context), or should I choose a different name? The wrapper just maps the low-level C functions to more type-safe and object-oriented equivalents and is of course under a free license.

Feel free to use “Nitrokey” in the name. :slight_smile:

That’s great! Could you estimate, when it would be available? I would willingly test it.

@jan Great, thanks!
@szszszsz I’m currently cleaning up the code and writing documentation for the library. Hopefully I can publish a first version tomorrow.

I released the library nitrokey-rsGit repository, documentation, crates.io. Finishing the CLI tool will now go rather fast. Yet I first want to check whether it is possible to integrate this with nitrocli (see nitrocli issue #2). I’ll post an update here once there is something to test.

1 Like