This file provides orientation for coding agents working in this repository. For deeper reference, see the linked files below.
This project is an SSH client library built with Kotlin coroutines, Kaitai Struct, and KStateMachine.
What this project provides:
- SSH protocol message parsing/serialization (RFCs 4250-4256, 4419, 5656, 8308, 8709, 8731, 9142)
- Async Kotlin SSH client API (
SshClient,SshSession) - Key exchange: curve25519, ML-KEM hybrid, ECDH (nistp256/384/521), DH group14/16/18, DH group-exchange
- Encryption: chacha20-poly1305, AES-GCM, AES-CTR, AES-CBC, 3DES-CBC
- MACs: HMAC-SHA2-256/512, HMAC-SHA1 (with ETM variants)
- Host key verification: Ed25519, Ed448, ECDSA (nistp256/384/521), RSA (SHA-256, SHA-512)
- Password, keyboard-interactive, and public key authentication
- Interactive shell sessions with PTY support
- SFTP file transfer (draft-ietf-secsh-filexfer)
- Port forwarding: local, remote, dynamic (SOCKS5)
- Agent forwarding with session binding
- Pluggable transport layer (TCP via Ktor, or custom)
Current limitations:
- Client-only (no server implementation)
- Minimize hand-written parsing — All SSH wire protocol messages are defined in Kaitai Struct (
.ksyfiles). Do not write manual byte-level parsers; add or extend.ksydefinitions instead. - Explicit, inspectable state machine — Connection lifecycle states and transitions live in KStateMachine configuration. State and transition logic must be readable from the KStateMachine setup; do not encode implicit state in ad-hoc flags or conditionals outside the state machine.
This is a multi-module Gradle project:
:protocol— Internal. Kaitai Struct code generation from.ksydefinitions. Generates Java classes inorg.connectbot.sshlib.protocol. Hidden from library consumers viaimplementationdependency.:sshlib— Core SSH library. Public API:SshClient,SshSession,SshClientConfig,SftpClient,BlockingSshClient. API tracked insshlib/api.txtvia Metalava.:testapp— Interactive CLI client for manual testing.
./gradlew :sshlib:compileKotlin # fast compile check
./gradlew build # compile + test all modules
./gradlew :sshlib:build # compile + test library only
./gradlew :sshlib:test # unit and integration tests (requires Docker)
./gradlew :protocol:kaitai # regenerate Kaitai Struct classes
./gradlew :sshlib:metalavaGenerateSignature # update api.txt
./gradlew :sshlib:metalavaCheckCompatibility # verify against api.txt
./gradlew :testapp:installDist # build CLI clientRun a single test class:
./gradlew :sshlib:test --tests "org.connectbot.sshlib.crypto.AlgorithmsTest"- Modify
.ksyfiles in:protocolif changing the wire protocol. - Run
./gradlew buildto regenerate classes and verify the whole project. - Run
./gradlew :sshlib:metalavaGenerateSignatureif you intentionally changed the public API. - Run
./gradlew :sshlib:testto run unit and integration tests (requires Docker).
- Internal implementation — architecture, Kaitai Struct usage, concurrency rules, coding guidelines
- Integration testing — test servers, compatibility quirks, test keys
- README.md — user-facing project overview and API examples
- sshlib/api.txt — tracked public API signature