A comprehensive server management tool for SSH connections, server monitoring, installation management, and administration of multiple servers including Proxmox VE hosts, routers, and other remote systems.
- Connect to multiple configured servers using aliases
- Support for Proxmox VE, routers, and any SSH-accessible host
- SSH key and password authentication
- Smart port fallback and connection handling
- Run adβhoc commands on a host via
exec - Pass environments and working directory with
--env KEY=VALand--workdir DIR - Interactive TUIs (htop/btop) with proper PTY sizing and live resize
- Robust
--delimiter handling; options can be placed before or after alias
- Real-time server status monitoring
- Resource usage tracking (CPU, memory, disk)
- Service status checks
- Network connectivity monitoring
- Automated software installation and updates
- Package management across different distributions
- Configuration deployment and management
- Service orchestration and management
- User and permission management
- Security audit tools
- Backup and restore operations
- Log monitoring and analysis
-
Install dependencies:
pip install -r requirements.txt
-
Copy config and edit:
cp sofilab.conf.sample sofilab.conf
-
Run commands (works on macOS, Linux, Windows):
python sofilab.py --help python sofilab.py status pmx python sofilab.py login pmx python sofilab.py run-scripts pmx
-
Optional install shortcut:
- macOS/Linux:
python sofilab.py installcreates/usr/local/bin/sofilabsymlink. - Windows: create a
sofilab.cmdwrapper that runspython sofilab.pyand place it on your PATH.
- macOS/Linux:
-
Clone the repository:
git clone https://github.com/arafatx/sofilab.git cd sofilab -
Install Python dependencies (auto-installs on first run too):
pip install -r requirements.txt
-
Create your configuration:
cp sofilab.conf.sample sofilab.conf nano sofilab.conf # Edit with your server details -
Install the CLI globally (macOS/Linux):
python sofilab.py install
-
Verify installation:
sofilab --version
Now you can use sofilab from anywhere!
If you prefer not to install globally, you can run directly with Python:
python sofilab.py login pmx-
Create your configuration from the sample:
cp sofilab.conf.sample sofilab.conf
-
Edit the configuration with your server details:
nano sofilab.conf
Example configuration:
[pmx,pmx-home] host="192.168.1.100" user="root" password="your_password" port="22" keyfile="ssh/pmx_key"
-
Connect to your servers:
# Connect to Proxmox sofilab login pmx # Connect to router sofilab login router
The sofilab.conf file uses a simple block format (no scripts= needed; scripts are now discovered from folders):
[alias1,alias2,alias3]
host="IP_ADDRESS"
user="USERNAME"
password="PASSWORD" # Optional
port="SSH_PORT" # Optional, defaults to 22
keyfile="ssh/alias_key" # OptionalYou can run local scripts on remote hosts in two ways:
- Single scripts under
scripts/main/(recommended for adβhoc):
scripts/main/update.sh
scripts/main/tools/net/ping-check.sh
Run:
sofilab run-script --host-alias pmx update.sh
sofilab run-script --host-alias pmx tools/net/ping-check.sh -- --count 5- Ordered sets under
scripts/sets/<name>/(priority by number):
scripts/sets/proxmox/
10_update.sh
20_secure.sh
30_setup-2fa.sh
_env # optional KEY=VALUE for all scripts
_args/20_secure.args # optional perβscript args
Rules:
- Numbered scripts (e.g.,
5_*.sh,10_*.sh) run first, sorted by numeric prefix (1+ digits) - Unnumbered scripts run afterwards, sorted alphabetically
Run:
# Preview order and args
sofilab run-scripts --host-alias pmx --set proxmox --dry-run -- --flag1 A --flag2 "B C"
# Execute with common args applied to each
sofilab run-scripts --host-alias pmx --set proxmox -- --flag1 A --flag2 "B C"Execution model and interpreters:
-
SofiLab uploads scripts to
~/.sofilab_scripts/on the remote and removes them after execution. -
Scripts execute on the remote host; your local OS does not affect script execution.
-
By default SofiLab invokes a POSIX shell (sh/bash) to run scripts. Use portable
.shfor maximum compatibility (BusyBox, Bash, Debian/Alpine, Proxmox). -
If you want nonβshell steps (Python/Node/etc.), ensure the interpreter exists on the remote and call it from a shell wrapper, for example:
#!/usr/bin/env sh exec python3 my_step.py "$@"
During execution, SofiLab sets useful environment variables:
SSH_PORT: configured SSH port for the hostACTUAL_PORT: effective port used (after autoβdetection)ADMIN_USER: remote usernameSSH_KEY_PATH: path to private key (without.pub) if usedSSH_PUBLIC_KEY: public key contents if available
- SSH key (if
keyfilespecified orssh/<alias>_keyexists) - Password (if specified in config)
- Direct SSH (uses SSH agent or default keys)
# Show help and available commands
sofilab --help
# Show version information
sofilab --version
# Connect using any configured alias
sofilab login pmx-home
sofilab login router
sofilab login rt
# Reboot a server by alias (optional wait)
sofilab reboot pmx # issue reboot and exit
sofilab reboot pmx --wait # wait up to 180s by default
sofilab reboot pmx --wait 300 # custom timeout seconds
# Copy files (scp-like; preferred)
# Remote paths use alias:/path
sofilab cp pmx:/var/log/syslog ./logs
sofilab cp -r pmx:/etc/nginx ./backups
sofilab cp ./notes.txt pmx:~/uploads
sofilab cp -r ./mydir pmx:~/projects
# List files on remote host (SFTP)
sofilab ls-remote pmx ~Run a oneβoff command on a host. Use -- to separate SofiLab options from the remote command and its args.
# Basic
sofilab exec pmx -- uname -a
# With environment and working directory
sofilab exec pmx --workdir /var/log -- tail -n 50 syslog
sofilab exec pmx --env TERM=xterm-256color -- htop
# TTY control for TUIs
sofilab exec --host-alias pmx --tty -- btop
sofilab exec pmx --no-tty -- ls -la /etcNotes:
- You may place
--env,--workdir,--tty,--no-ttyeither before or after the--delimiter; SofiLab salvages them reliably. For clarity, placing them before--is recommended. - In TTY mode, SofiLab allocates the remote PTY with your local terminal size and TERM, and propagates SIGWINCH on resize. Fullβscreen apps (btop/htop) now use the full window and resize live.
- The remote shell is detected (bash if available, otherwise sh) and used as
shell -c '<command>'for consistent behavior.
-
Flexible alias options: you can use positionals or named flags anywhere.
--host-alias pmxor--hostname pmxwork with all host commands.
-
Login/status examples:
sofilab login pmxsofilab login --hostname pmxsofilab status --host-alias pmx
-
Run one script (with args):
sofilab run-script --host-alias pmx update.shsofilab run-script --host-alias pmx tools/net/ping-check.sh -- --count 3
-
Run an ordered set (same args applied to each):
sofilab run-scripts --host-alias pmx --set proxmoxsofilab run-scripts --host-alias pmx --set proxmox -- --flag value
-
TTY control (place before
--if you use it):--ttyor--no-ttywith any command that executes scripts.
-
Preview what will run (shows args from config):
sofilab list-scripts pmx
Tips:
- Use quotes in
sofilab.conffor arguments with spaces (parsed shellβstyle). - CLI
--stops option parsing; anything after goes to the script(s). - If a router lacks SFTP (e.g., BusyBox/Dropbear), SofiLab falls back to a shell upload automatically.
- Logs live under
logs/. Tail recent output:sofilab logs main 100,sofilab logs remote 200,sofilab clear-logs remote.
- Add a host to
sofilab.conf - Place single scripts under
scripts/main/ - Or create a set under
scripts/sets/<name>/with numbered scripts - Preview:
sofilab run-scripts --host-alias <alias> --set <name> --dry-run - Execute:
sofilab run-scripts --host-alias <alias> --set <name>
- Host key mismatch:
sofilab reset-hostkey <alias>then retry. - PATH/wrapper issues (Windows):
sofilab doctor --repair-path. - SSH authentication: ensure key path in
keyfileis correct and readable. If a matchingssh/<alias>_keyexists, itβs autoβused.
sofilab/
βββ README.md
βββ sofilab.py
βββ sofilab.conf.sample
βββ scripts/
β βββ main/
β β βββ update.sh
β β βββ tools/net/ping-check.sh
β βββ sets/
β β βββ proxmox/
β β βββ 10_update.sh
β β βββ 20_secure.sh
β β βββ 30_setup-2fa.sh
β β βββ _env
β β βββ _args/20_secure.args
β βββ hooks/
β βββ login/scripts/main.py
β βββ status/scripts/main.py
β βββ reboot/scripts/main.py
βββ ssh/
βββ pmx_key
βββ pmx_key.pub
Note: The ssh/ directory and sofilab.conf are excluded from git for security.
Use the Python CLI:
# Install sofilab globally (macOS/Linux)
python sofilab.py install
# Uninstall
python sofilab.py uninstall- SSH keys are stored in the
ssh/directory - Passwords in
sofilab.confshould be secured appropriately - The script supports SSH agent for additional security
- Consider using SSH key authentication over passwords when possible
To add a new server configuration:
-
Edit
sofilab.conf -
Add a new block with your preferred aliases:
[myserver,srv] host="192.168.1.100" user="admin" password="your_password" # Optional port="22" # Optional keyfile="ssh/myserver_key" # Optional
-
Generate SSH keys if using key authentication:
ssh-keygen -t rsa -b 4096 -f ssh/myserver_key ssh-copy-id -i ssh/myserver_key.pub user@192.168.1.100
- Python 3.8+
- Paramiko (autoβinstalled by SofiLab when needed)
- SSH server on the remote hosts