This project is an implementation of an SSH client and server in C++ from scratch. The implementation follows the SSH-2 protocol standards and provides secure communication using Elliptic Curve Diffie-Hellman key exchange and AES-256-CBC encryption.
- SSH-2 protocol implementation
- Elliptic Curve Diffie-Hellman key exchange
- RSA Signatures for verifying server identity
- AES-256-CBC encryption with HMAC-SHA256 for integrity
- Basic client and server functionality
- Support for both encrypted and unencrypted communication (for learning purposes)
The project is structured around the following key components:
- TCPPacket Class: Base class for all packet types
- SSHPacket Class: Specific implementation for SSH protocol packets
- NetworkClient/Server: Basic client/server without encryption
- SSHClient/Server: Adds encryption and key exchange to the base classes
- Crypto Library: Custom implementations of cryptographic primitives
To build the project, you'll need CMake and a C++20 compliant compiler:
mkdir build
cd build
cmake ..
makeAfter building, you can run the application in different modes:
./sshctrl demoThis will run a simple test that creates an unencrypted server and client, exchanges messages, and then shuts down.
./sshctrl serverThis will start an SSH server on port 2222 and wait for client connections.
./sshctrl client <host> <port>This will connect to an SSH server at the specified host and port. If no host and port is given, it defaults to 127.0.0.1 on port 2222
- Protocol Exchange: Client and server exchange protocol version strings
- Key Exchange:
- Exchange KEXINIT packets to negotiate algorithms
- Perform Elliptic Curve Diffie-Hellman key exchange
- Compute shared secret and session keys
- Service Request: Client requests a service (typically ssh-userauth)
- Authentication: Client authenticates (password, public key, etc.)
- Connection: After successful authentication, client can open channels for terminal sessions, forwarding, etc.
This implementation is meant for educational purposes and should not be used in production environments. While it implements the core security features of SSH, it may contain vulnerabilities or incomplete implementations of certain aspects of the protocol.
This project demonstrates:
- Network Programming: Socket programming for client-server communication
- Cryptography: Implementation of cryptographic primitives and protocols
- Protocol Design: Understanding of the SSH protocol
- C++ Programming: Object-oriented design, memory management, etc.
This project is for educational purposes only.