Skip to content

Repository files navigation

Ubuntu CLI

npm version License: 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

npm install -g ubuntu-cli

Using npx (No Installation Required)

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:

sudo ucli <command>

Available Commands

Initial Setup

Updates system packages, hardens SSH, and optionally installs Fail2Ban:

sudo ucli initial-setup

Network Configuration

Interactive netplan configuration for a network interface:

sudo ucli network-config

Firewall Configuration

UFW reset with role-based rules (redis, mariadb, api, ui-app, vpn, deployinator):

sudo ucli firewall-config

Authorized Key Management

Add an SSH public key to a user account:

sudo ucli authorized-key

Development

Clone and Install

git clone https://github.com/yigitahmetsahin/ubuntu-cli.git
cd ubuntu-cli
npm install

Build

npm run build

Run Locally

During development, you can run without building:

sudo npx ts-node src/main.ts <command>

Or after building:

sudo node dist/main <command>

Testing

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 on GitHub.

About

Ubuntu configurator cli

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages