A powerful ASP.NET Core API service that executes shell commands remotely with elevated privileges. This service is designed to run commands on Linux servers, making it ideal for deployment automation, server management, and CI/CD workflows.
Command Center provides a REST API endpoint that:
- Executes multiple shell commands in a specified directory
- Runs with elevated privileges (root) for system administration tasks
- Returns both standard output and error streams
- Perfect for automating deployments, running migrations, managing git repositories, and other server maintenance tasks
- 🚀 Execute multiple commands in sequence
- 📁 Change working directory before execution
- 📝 Capture all output and errors
- 🔧 Built with ASP.NET Core 9.0
- 🐧 Linux-focused (uses
/bin/bash
) - 🔄 Auto-restart on failure via systemd
POST http://your-server:7262/commands/run
{
"path": "/var/www/your-app",
"commands": [
"git pull",
"dotnet restore",
"dotnet build",
"systemctl restart your-app"
]
}
{
"success": true,
"output": "$ git pull\nAlready up to date.\n$ dotnet restore\nRestore completed...",
"error": ""
}
- Ubuntu/Debian Linux server
- Root or sudo access
- .NET 9.0 Runtime
# Add Microsoft package repository
sudo add-apt-repository ppa:dotnet/backports
sudo apt-get update
# Install .NET SDK and Runtime
sudo apt-get install -y dotnet-sdk-9.0
sudo apt-get install -y aspnetcore-runtime-9.0
On your development machine:
# Build the project
dotnet publish -c Release -o ./publish
# Copy to server
scp -r ./publish/* user@your-server:/var/command/
Create the service file:
sudo nano /etc/systemd/system/command-center.service
Add the following content:
[Unit]
Description=API Command Center for running elevated commands in Webserver Applications
After=network.target
[Service]
WorkingDirectory=/var/command
ExecStart=dotnet /var/command/"Command Center.dll"
Restart=always
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=command-center
User=root
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=ASPNETCORE_URLS=http://localhost:7262
Environment=HOME=/root
Environment=USER=root
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=multi-user.target
# Reload systemd configuration
sudo systemctl daemon-reload
# Enable service to start on boot
sudo systemctl enable command-center
# Start the service
sudo systemctl start command-center
# Check service status
sudo systemctl status command-center
# View logs
sudo journalctl -u command-center -f
If you need external access:
# Open port 7262
sudo ufw allow 7262/tcp
-
Network Security
- Only bind to localhost (default configuration)
- Use a reverse proxy (nginx) with authentication
- Implement IP whitelisting
-
API Security
- Add authentication middleware
- Implement API key validation
- Use HTTPS in production
-
Command Validation
- Whitelist allowed commands
- Validate paths
- Add command timeouts
server {
listen 80;
server_name your-domain.com;
location /command-center/ {
auth_basic "Command Center";
auth_basic_user_file /etc/nginx/.htpasswd;
proxy_pass http://localhost:7262/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
{
"path": "/var/www/myapp",
"commands": [
"git config --global --add safe.directory /var/www/myapp",
"git pull origin main",
"npm install",
"npm run build",
"pm2 restart myapp"
]
}
{
"path": "/var/www/myapp",
"commands": [
"php spark migrate --force",
"php spark cache:clear",
]
}
{
"path": "/home/docker/myapp",
"commands": [
"docker-compose pull",
"docker-compose up -d",
"docker system prune -f"
]
}
# Check logs
sudo journalctl -u command-center -n 50
# Verify .NET installation
dotnet --info
# Check file permissions
ls -la /var/command/
# Add safe directory
git config --global --add safe.directory /path/to/repo
# Fix ownership
chown -R root:root /path/to/repo/.git
# Find process using port
sudo netstat -tlnp | grep 7262
# Change port in service file
Environment=ASPNETCORE_URLS=http://localhost:7263
This project is licensed under the MIT License - see the LICENSE file for details.
We welcome contributions to Command Center! This project is open source and community-driven.
-
Fork the Repository
git clone https://github.com/MEITWorld/Command-Center.git cd command-center
-
Create a Feature Branch
git checkout -b feature/your-feature-name
-
Make Your Changes
- Write clean, documented code
- Follow C# coding conventions
- Add unit tests for new features
- Update documentation as needed
-
Test Your Changes
dotnet test dotnet run
-
Commit Your Changes
git add . git commit -m "Add feature: description of your changes"
-
Push to Your Fork
git push origin feature/your-feature-name
-
Create a Pull Request
- Go to the original repository
- Click "New Pull Request"
- Select your feature branch
- Describe your changes in detail
- Use C# naming conventions
- Keep methods small and focused
- Add XML documentation comments for public APIs
- Use meaningful variable and method names
- Write unit tests for new features
- Ensure all tests pass before submitting PR
- Aim for good code coverage
- Update README.md for new features
- Add inline comments for complex logic
- Include examples for new functionality
- Ensure your PR description clearly describes the problem and solution
- Include the relevant issue number if applicable
- Update the README.md with details of changes to the interface
- Your PR will be reviewed by maintainers
- Make requested changes if any
- Once approved, your PR will be merged
- Security Enhancements: Authentication, authorization, rate limiting
- Features: Command queuing, async execution, webhooks
- Documentation: Tutorials, examples, translations
- Testing: Unit tests, integration tests, performance tests
- Bug Fixes: Check the issues page for reported bugs
Found a bug or have a feature request? Please create an issue:
- Check if the issue already exists
- Use a clear and descriptive title
- Provide detailed steps to reproduce (for bugs)
- Include system information (OS, .NET version)
- Add relevant logs or error messages
Please note that this project follows a Code of Conduct. By participating, you are expected to:
- Be respectful and inclusive
- Welcome newcomers and help them get started
- Focus on constructive criticism
- Respect differing viewpoints and experiences
- 📧 Email: [software@nexgen.co.zm]
Thank you for contributing to Command Center! 🚀