MiSSHod, an SSH client in Zig

MiSSHod is a minimal, experimental SSH client implemented as a library.

It’s an SSH client, in pure Zig using std.crypto. It’s not safe, it’s not secure, don’t actually use it for anything important.

However, it’s quite small. It’s very flexible and I hope at some point to get it running on a small microcontroller.

I’ve had a very fun week writing it. Though, I won’t be sad to close my browser tabs full of RFCs.

Enjoy.

11 Likes

For anyone else interested in how the SSH protocol works, I’ve written up some notes. misshod/doc/primer.md at main · ringtailsoftware/misshod · GitHub

1 Like

This is very cool! Do you plan to add support for using it as a server? I can think of lots of toy ssh server projects I could use this for.

I don’t have any plans for server support at the moment, though a lot of the code would be transferable. Ideally, I’d like to get it onto an esp32 or other wireless microcontroller.

It’s very rough, but I’ve added a basic server example.
Right now, I’m just concerned with the protocol. The “msshd” example in the repo only handles a single connection at a time and just echoes back what it receives. It handles public key and password auth via events to the app code where it can make a decision - but right now just lets anyone with any key connect.

Opening up a real pty and shell would certainly be possible, but not something I’d recommend anyone does due to the immaturity of this project.

How do you imagine connecting an existing app to an ssh server?

Would you want the server to fork-exec a separate app via the OS, or to link existing code with the sshd’s select() loop? Or perhaps to start a thread with your code and communicate via file descriptors?

3 Likes

I would want to drive MisshodServer at the IO layer level using my own async IO capabilities. Whatever forking or thread spawning I need I would like to do myself.

afaict, this is how misshod is designed to be used already, which is perfect.

2 Likes