NetBurner 3.5.6
PDF Version
SSH Server

SSH Minimal Server Example

Overview

This NetBurner application implements a minimal SSH server that listens for incoming SSH client connections on TCP port 22. The server demonstrates basic SSH functionality using the NetBurner's built-in SSH library and certificate management system.

Features

  • SSH server listening on port 22
  • Automatic certificate and key generation
  • Bidirectional communication between SSH client and server
  • Serial console integration for monitoring and sending data
  • Connection timeout handling (120 seconds)
  • TCP error state reporting
  • Multi-client support with connection queuing

Architecture

The application consists of two main components:

SSH Server Task

  • Runs as a separate high-priority task
  • Listens for incoming SSH connections
  • Handles client authentication and session management
  • Processes incoming data from SSH clients
  • Manages connection lifecycle and cleanup

Main User Interface

  • Provides serial console interface for monitoring
  • Allows sending data to connected SSH clients via keyboard input
  • Displays connection status and diagnostic information

Usage Instructions

Setup

  1. Compile and load the application into your NetBurner device
  2. Ensure the device is connected to your network
  3. Run MTTTY or similar terminal emulator to connect to the device's USB/Serial port

Connecting SSH Clients

  1. Use any SSH client (PuTTY, OpenSSH, etc.)
  2. Connect to the NetBurner device's IP address on port 22
  3. The server will display a welcome message: "Welcome to the NetBurner SSH Server"
  4. Connection details will be shown on both the SSH client and serial console

Sending Data

  • From Serial Console: Type ASCII strings followed by Enter to send data to connected SSH clients
  • From SSH Client: Any data sent from the SSH client will be displayed on the serial console

Configuration

Key Parameters

  • SSH_LISTEN_PORT: Server listening port (default: 22)
  • CONNECTION_TIMEOUT: Inactivity timeout in seconds (default: 120)
  • BUFSIZE: Buffer size for data transmission (default: 4096 bytes)

Security

  • Uses NetBurner's built-in SSH key management
  • Automatic certificate creation is enabled via EnableOnboardCertificateCreation()
  • Standard SSH encryption and authentication protocols

Error Handling

The application includes comprehensive error handling for various TCP and SSH conditions:

  • TCP connection errors (timeout, reset, abort)
  • SSH negotiation failures
  • Session establishment failures
  • Socket availability issues
  • Connection timeouts

Error states are reported through the serial console with descriptive messages.

Technical Details

Memory Usage

  • SSH Server task stack: 4x standard user task stack size
  • Separate receive and transmit buffers (4KB each)
  • Efficient memory management with proper cleanup

Network Interface

  • Automatically detects and uses the first available network interface
  • Displays IP address and interface information on startup
  • Supports standard Ethernet connections

Task Management

  • SSH server runs at higher priority than UserMain
  • Proper task synchronization and resource management
  • Clean connection handling and resource cleanup

Dependencies

Build Requirements

  • NetBurner development environment
  • SSH library support enabled in NetBurner configuration
  • Certificate generation support

Troubleshooting

Common Issues

  1. Connection refused: Verify network connectivity and firewall settings
  2. Authentication failures: Check SSH key configuration
  3. Timeouts: Adjust CONNECTION_TIMEOUT value if needed
  4. Memory issues: Monitor task stack usage and buffer sizes

Diagnostic Features

  • System diagnostics are enabled for development (consider disabling for production)
  • Detailed error reporting through serial console
  • Connection state monitoring and logging