ubuntu-cli
Version:
A powerful CLI tool for hardening and configuring Ubuntu servers with interactive prompts
133 lines (90 loc) • 2.98 kB
Markdown
# Ubuntu CLI
[](https://www.npmjs.com/package/ubuntu-cli)
[](https://opensource.org/licenses/MIT)
A powerful CLI tool for hardening and configuring Ubuntu servers with interactive prompts. Built with NestJS and nest-commander, `ubuntu-cli` provides a modern TypeScript/Node.js implementation for common server security and configuration tasks.
## Features
- 🔒 **Security Hardening**: SSH hardening, Fail2Ban installation, and firewall configuration
- 🌐 **Network Configuration**: Interactive netplan configuration
- 🔑 **SSH Key Management**: Easy authorized key management for users
- 🛡️ **Firewall Management**: Role-based UFW rules for various server types
- ✨ **Interactive Prompts**: User-friendly command-line interface
- 📦 **TypeScript**: Fully typed for reliability and maintainability
## Installation
### Global Installation
```bash
npm install -g ubuntu-cli
```
### Using npx (No Installation Required)
```bash
npx ubuntu-cli <command>
```
## Prerequisites
- Node.js 20 or higher
- Ubuntu server (tested on Ubuntu 20.04+)
- Root privileges (`sudo`) for system configuration commands
## Usage
Run commands with `ucli` (if installed globally) or `npx ucli`:
```bash
sudo ucli <command>
```
### Available Commands
#### Initial Setup
Updates system packages, hardens SSH, and optionally installs Fail2Ban:
```bash
sudo ucli initial-setup
```
#### Network Configuration
Interactive netplan configuration for a network interface:
```bash
sudo ucli network-config
```
#### Firewall Configuration
UFW reset with role-based rules (redis, mariadb, api, ui-app, vpn, deployinator):
```bash
sudo ucli firewall-config
```
#### Authorized Key Management
Add an SSH public key to a user account:
```bash
sudo ucli authorized-key
```
## Development
### Clone and Install
```bash
git clone https://github.com/yigitahmetsahin/ubuntu-cli.git
cd ubuntu-cli
npm install
```
### Build
```bash
npm run build
```
### Run Locally
During development, you can run without building:
```bash
sudo npx ts-node src/main.ts <command>
```
Or after building:
```bash
sudo node dist/main <command>
```
### Testing
```bash
npm test
```
## Publishing
This package uses automated GitHub Actions for publishing to npm. When you create a release on GitHub, it will automatically:
1. Run tests
2. Build the package
3. Publish to npm
## Notes
- The CLI enforces root usage for safety
- File backups are created automatically (e.g., SSH config backups)
- Interactive prompts guide you through configuration options
- All system commands are executed safely with proper error handling
## License
MIT
## Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
## Support
If you encounter any issues or have questions, please [open an issue](https://github.com/yigitahmetsahin/ubuntu-cli/issues) on GitHub.