Skip to main content

CLI for QNAP NAS management

Project description

qnap

codecov

A CLI for QNAP NAS management. It is designed for both interactive use and automation: human-friendly tables by default, stable JSON contracts on inspection commands, and a schema command for agent introspection.

Supported platforms: Linux and macOS.

Installation

cargo install qnap

Or build from source:

git clone https://github.com/rvben/qnap-cli
cd qnap-cli
make install

Quick Start

# Save connection settings and password
qnap login --host nas.local --username admin

# Inspect the NAS
qnap info
qnap status
qnap volumes
qnap shares
qnap files ls /Public

# Structured output for automation
qnap status --json
qnap files stat /Public/example.txt --json

Commands

Command Description
login Save credentials and verify connectivity
info Model, firmware, hostname, serial, uptime
status CPU, RAM, temperature, uptime
volumes Storage volumes and installed disks
shares Shared folders
network Network adapters, IPs, MACs, DNS (--json)
config Show saved host, username, TLS settings, and file paths (--json)
files ls <PATH> List files and directories (--all, -r recursive, --json)
files stat <PATH> Normalized metadata plus raw QNAP fields (--json)
files find <PATH> <PATTERN> Recursive glob search (*.txt, backup*) (--json)
files mkdir <PATH> Create a directory
files rm <PATH>... Delete one or more files or directories
files mv <SRC> <DST> Move or rename a file or directory
files cp <SRC> <DST> Copy a file or directory (--overwrite)
files upload <LOCAL> <REMOTE_DIR> Upload a file or directory (--overwrite, -r recursive)
files download <REMOTE> [LOCAL] Download a file or directory (-r recursive)
dump [DIR] Save raw API responses for debugging
schema Print full command schema
completions <SHELL> Print shell completion script (bash, zsh, fish)

Global Flags

These flags work on every authenticated command, including login.

Flag Description
--host <HOST> Override the NAS host for one command. HTTPS only.
--username <USERNAME> Override the username for one command.
--insecure Skip TLS certificate verification for one command.
--secure Force TLS certificate verification for one command.
--password-stdin Read the password from stdin.

Examples:

printf '%s\n' 'secret-password' | qnap --password-stdin info
qnap --host https://nas.local --username admin status
qnap --secure volumes --json

Authentication

qnap login [--host <HOST>] [--username <USERNAME>] [--insecure | --secure]

qnap login verifies the credentials before saving anything. Host, username, and the saved TLS verification preference are stored in config.toml. The password is stored separately in credentials.toml.

The CLI requires HTTPS. Plain http:// targets are rejected. If your NAS uses a self-signed certificate, use --insecure or QNAP_INSECURE=1 explicitly.

If you do not want local password persistence, skip qnap login and provide QNAP_HOST, QNAP_USERNAME, and QNAP_PASSWORD directly when running commands.

JSON Output

The following commands support --json with stable, typed output:

  • info
  • status
  • volumes
  • shares
  • files ls
  • files stat

Highlights:

  • status --json uses numeric fields such as cpu_usage_pct, mem_total_mb, and temp_c.
  • volumes --json includes status_code, pool_id, and per-disk temp_c.
  • shares --json uses items_count as a number.
  • files ls --json uses size_bytes and modified_epoch.
  • files stat --json returns normalized fields plus a raw object for unnormalized QNAP metadata.

Use qnap schema for the full machine-readable command and output contract.

Environment Variables

Environment variables override local files.

Variable Description
QNAP_HOST NAS host, for example https://nas.local or nas.local
QNAP_USERNAME Username
QNAP_PASSWORD Password
QNAP_INSECURE 1/true/yes to skip TLS verification, 0/false/no to force verification
NO_COLOR Disable colored output

Stored Files

config.toml stores host, username, and TLS verification preference. credentials.toml stores the password separately in plaintext on the local machine.

Platform Config file Credentials file
macOS ~/Library/Application Support/qnap/config.toml ~/Library/Application Support/qnap/credentials.toml
Linux ~/.config/qnap/config.toml ~/.config/qnap/credentials.toml

Security

  • Passwords are never accepted as CLI flags.
  • HTTPS is required for NAS connections.
  • TLS verification is enabled by default.
  • credentials.toml is written atomically.
  • On Unix, credentials.toml is restricted to owner-only (0600) permissions.
  • On Unix, the config directory is tightened to owner-only (0700) permissions.
  • Symlink and non-regular-file credential targets are rejected.
  • If you do not want local password persistence, use environment variables or --password-stdin.

Shell Completions

Generate and install completions for your shell:

# Zsh — add to ~/.zshrc or drop in a $fpath directory
qnap completions zsh > ~/.zfunc/_qnap
echo 'fpath=(~/.zfunc $fpath)' >> ~/.zshrc
echo 'autoload -Uz compinit && compinit' >> ~/.zshrc

# Bash
qnap completions bash > /etc/bash_completion.d/qnap
# or for a user install:
qnap completions bash > ~/.local/share/bash-completion/completions/qnap

# Fish
qnap completions fish > ~/.config/fish/completions/qnap.fish

Compatibility

Tested against QTS 5.1.x and 5.2.x. The core authentication and file manager APIs have been stable since QTS 4.3, but qnap dump is the recommended way to capture compatibility issues from older or unusual firmware builds.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qnap_cli-0.1.9.tar.gz (59.1 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

qnap_cli-0.1.9-py3-none-win_amd64.whl (2.8 MB view details)

Uploaded Python 3Windows x86-64

qnap_cli-0.1.9-py3-none-manylinux_2_28_x86_64.whl (2.9 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

qnap_cli-0.1.9-py3-none-manylinux_2_28_aarch64.whl (2.8 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ ARM64

qnap_cli-0.1.9-py3-none-macosx_11_0_arm64.whl (2.7 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

qnap_cli-0.1.9-py3-none-macosx_10_12_x86_64.whl (2.8 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

Details for the file qnap_cli-0.1.9.tar.gz.

File metadata

  • Download URL: qnap_cli-0.1.9.tar.gz
  • Upload date:
  • Size: 59.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for qnap_cli-0.1.9.tar.gz
Algorithm Hash digest
SHA256 12a6004f803fab969c5390431e6db98da08932fd85ff678cdbba5fa011f937a7
MD5 0178d82e724157360cb85eca57c82aa1
BLAKE2b-256 06b762e12face23dca667dbf4e2dcc7303b58cc1ef2cead69c4ddb85a5634fea

See more details on using hashes here.

File details

Details for the file qnap_cli-0.1.9-py3-none-win_amd64.whl.

File metadata

  • Download URL: qnap_cli-0.1.9-py3-none-win_amd64.whl
  • Upload date:
  • Size: 2.8 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for qnap_cli-0.1.9-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 c58b45e78073eba56563ce69311e4bf93f98bddf2761942726ee60fef270292b
MD5 448118e46af13accd336b851c81acd9a
BLAKE2b-256 c358704b483ed3dc81304bc0c7035dd2c04c48711f57c5004e1eac72435c91a0

See more details on using hashes here.

File details

Details for the file qnap_cli-0.1.9-py3-none-manylinux_2_28_x86_64.whl.

File metadata

  • Download URL: qnap_cli-0.1.9-py3-none-manylinux_2_28_x86_64.whl
  • Upload date:
  • Size: 2.9 MB
  • Tags: Python 3, manylinux: glibc 2.28+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for qnap_cli-0.1.9-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 10991bed59f969024f86e7d3c2ddc917b4a0b05c0f9f47ab2df2badc82cf5d79
MD5 aae38c0a08b04ab70d0ba52789eb2534
BLAKE2b-256 118bf29949479820ef10a7d3b84097e9f0d165675e10d2f9494d09874266c6ce

See more details on using hashes here.

File details

Details for the file qnap_cli-0.1.9-py3-none-manylinux_2_28_aarch64.whl.

File metadata

  • Download URL: qnap_cli-0.1.9-py3-none-manylinux_2_28_aarch64.whl
  • Upload date:
  • Size: 2.8 MB
  • Tags: Python 3, manylinux: glibc 2.28+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for qnap_cli-0.1.9-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 7af141669035265ef185375573fec5d35a68c214195b89c09f6ebd93a0a5deda
MD5 095ab824d785d15dd1757590c5686bf7
BLAKE2b-256 2590db4f38a9fe8f58b55a8a48ceae23911a109fa4fdb7ddff776708f0452de3

See more details on using hashes here.

File details

Details for the file qnap_cli-0.1.9-py3-none-macosx_11_0_arm64.whl.

File metadata

  • Download URL: qnap_cli-0.1.9-py3-none-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 2.7 MB
  • Tags: Python 3, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for qnap_cli-0.1.9-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 54da0cb8c1d42aaf1b4db494b5316e7a57ebb7f35e4a5c2c6f5e01a62adb59b9
MD5 fe0f2e51cfb1c7d6e4b87e98385c9450
BLAKE2b-256 2bf89d75867dc210acb512145cc6646336fb28a88e412d82de75f5afa8a04bda

See more details on using hashes here.

File details

Details for the file qnap_cli-0.1.9-py3-none-macosx_10_12_x86_64.whl.

File metadata

  • Download URL: qnap_cli-0.1.9-py3-none-macosx_10_12_x86_64.whl
  • Upload date:
  • Size: 2.8 MB
  • Tags: Python 3, macOS 10.12+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for qnap_cli-0.1.9-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 b0c7b337536142f3bf930dcac7f3881f424a2eb1aa707d2bdc0b044fcc1d4f30
MD5 07c80d330fde02a41ad3fc31465e77f2
BLAKE2b-256 8746588dbe148fdb06ace3ae579233af3369405af10f709d2cfb3d782c5b0a41

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page