(unssh: an [uns]ecure [sh]ell)
I built part of an SSH server. It’s enough to get a shell on the host machine using an OpenSSH client. This included implementing the binary protocol, performing key exchange, hooking up encryption and decryption, session management, PTY allocation, and launching shells or running commands.
It’s got no authentication mechanisms, doesn’t follow any standards for configuration, and could have serious security vulnerabilities. This was nothing more than a weekend project.
By far the hardest part was implementing the key exchange. I thought this would be easier given that there are detailed spec documents and reference implementations, but I underestimated how finicky it would be to get right and how hard it would be to debug, since even a single bit wrong somewhere is as broken as not implementing it at all.
The key exchange is implemented using the Diffie-Hellman Group 14 method, which I don’t actually understand, if I’m honest — again, I just followed the spec.
I actually found the spec wildly ambiguous and confusing in places. Things like:
SSH_MSG_CHANNEL_DATA
packets,
congrats! The spec doesn’t say anything about what this data is or how to use
it. It seems logical to write the bytes to the PTY master file descriptor, and
that turns out to be correct. But why the spec doesn’t specify this is beyond me.In the end, it kinda works. Please don’t use it.