An SSH protocol-based chat room built with Spring Boot and Apache MINA SSHD, supporting anonymous users to chat in real-time via SSH connections.
- ✅ SSH Protocol Support: Users can connect directly via SSH clients
- ✅ Anonymous Chat: No registration required, start chatting immediately
- ✅ Virtual Threads: Based on JDK 21 virtual threads, supporting high-concurrency connections
- ✅ Real-time Messages: Messages broadcast to all online users in real-time
- ✅ Message History: New users can see recent chat history when joining
- ✅ User Management: Display online user list and statistics
- ✅ Command Support: Built-in chat commands
- JDK 21 - Virtual threads support
- Spring Boot 3.2.1 - Application framework
- Apache MINA SSHD 2.11.0 - SSH server implementation
- Maven - Build tool
- JDK 21 or higher
- Maven 3.6+
mvn clean compile
mvn spring-boot:run
Or build JAR and run:
mvn clean package
java -jar target/ssh-chatroom-1.0.0.jar
Use SSH client to connect to the chat room:
ssh -p 2222 localhost
Or connect to remote server:
ssh -p 2222 your-server-ip
Note:
- Supports login with any username and password (anonymous mode)
- Default port is 2222, configurable in application settings
After successful connection, you'll see the welcome interface. Supports the following operations:
- Direct text input - Send chat messages
/help
- Show help information/users
- Show online user list/stats
- Show chat room statistics/quit
or/exit
- Exit chat room
╔══════════════════════════════════════════════════════════════╗
║ SSH Chat Room ║
║ ║
║ Welcome to SSH Chat Room! ║
║ - Type messages to start chatting ║
║ - Type '/help' for help ║
║ - Type '/users' to see online users ║
║ - Type '/quit' to exit chat room ║
║ ║
║ Powered by JDK21 virtual threads for high performance! ║
╚══════════════════════════════════════════════════════════════╝
Online users: 1 | Enter message: Hello everyone!
[14:30:25] Anonymous1: Hello everyone!
Online users: 2 | Enter message: /users
Online Users (2 users):
════════════════════════════════════════
• Anonymous1 (ID: 1) - /127.0.0.1:54321
• Anonymous2 (ID: 2) - /127.0.0.1:54322
════════════════════════════════════════
Main configuration in src/main/resources/application.yml
:
ssh:
server:
port: 2222 # SSH server port
host: 0.0.0.0 # Bind address
max-connections: 100 # Maximum connections
welcome-message: "Welcome to SSH Chat Room!"
logging:
level:
com.sshspring: DEBUG # Log level
The project fully utilizes JDK 21 virtual threads:
- Each SSH connection uses an independent virtual thread
- Message broadcasting uses virtual thread pool for concurrent sending
- Supports thousands of concurrent connections without exhausting system resources
- SshChatroomApplication - Spring Boot main application class
- SshServerConfig - SSH server configuration
- ChatRoomService - Chat room core service
- SshChatShellFactory - SSH Shell factory
- SshChatCommand - SSH command processor
- ChatUser - User model
- ChatMessage - Message model
src/main/java/com/sshspring/
├── SshChatroomApplication.java # Main application class
├── config/
│ └── SshServerConfig.java # SSH server configuration
├── model/
│ ├── ChatUser.java # User model
│ └── ChatMessage.java # Message model
├── service/
│ └── ChatRoomService.java # Chat room service
└── ssh/
├── SshChatShellFactory.java # SSH Shell factory
└── SshChatCommand.java # SSH command processor
Can easily extend the following features:
- User authentication and permission management
- Private messaging
- Chat room grouping
- Message persistence
- File transfer
- Bot integration
MIT License
Issues and Pull Requests are welcome!
For questions or suggestions, please create an Issue.