OpenCode custom tool for running remote bash commands over SSH.
Project description
remote-bash-tool
OpenCode 自定义工具:通过 SSH(读取 ~/.ssh/config)在远程机器执行 bash 命令,基于 asyncssh 支持异步调用。
OpenCode custom tool: run bash commands on remote hosts via SSH (reads ~/.ssh/config), powered by asyncssh with async support.
Install (uv)
uv venv
uv sync
Usage
示例:在终端中直接执行(无需单独脚本文件):
Example: run directly in terminal (no script file needed):
# 使用 uvx 直接运行
uvx --from remote-bash-tool remote-bash --host-alias prod-db --command "uptime"
# 在项目内,使用 uv
uv run remote-bash --host-alias prod-db --command "uptime"
# 或者安装到环境后
remote-bash --host-alias prod-db --command "uptime"
# 如果想要 JSON 输出
remote-bash --host-alias prod-db --command "df -h" --json
也支持模块方式运行:
Module invocation is also supported:
python -m remote_bash_tool --host-alias prod-db --command "uptime"
查看帮助:
Show help:
remote-bash --help
示例:在 Python 代码中直接调用工具方法。
Example: call from Python code:
import asyncio
from remote_bash_tool.tool import run
async def main() -> None:
result = await run(
{"host_alias": "prod-db", "command": "uptime", "stream_output": True}
)
print(result["stdout"])
asyncio.run(main())
OpenCode config (optional)
-
将工具模块挂载到 OpenCode(示例配置,参考 OpenCode 自定义工具指南进行调整):
-
Register the tool module in OpenCode (example config, adjust per OpenCode docs):
tools: - name: remote_bash module: remote_bash_tool.tool entrypoint: run
-
在 OpenCode 中调用工具:
-
Call the tool in OpenCode:
{ "host_alias": "prod-db", "command": "df -h", "timeout": 10, "stream_output": true }
CI & PyPI Publishing
-
CI:
.github/workflows/ci.yml会在 push/PR 时运行测试。 -
发布:
.github/workflows/publish.yml会在推送v*标签时构建并发布到 PyPI(使用 Trusted Publishing)。 -
首次发布:如果 PyPI 还没有该项目,先用 API Token 完成首发;首发后再在 PyPI 配置 Trusted Publisher 并切回 OIDC。
-
CI:
.github/workflows/ci.ymlruns tests on push/PR. -
Publish:
.github/workflows/publish.ymlbuilds and publishes onv*tags (Trusted Publishing). -
First publish: if the project does not exist on PyPI, use an API token once; then configure a Trusted Publisher and switch back to OIDC.
发布步骤示例:
Publish example:
git tag v0.1.0
git push origin v0.1.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file remote_bash_tool-0.2.0.tar.gz.
File metadata
- Download URL: remote_bash_tool-0.2.0.tar.gz
- Upload date:
- Size: 34.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
093b6183d8db866ca6f3eb69f3f56b6284ee0c8d3be320dd3b7a79cf6a567b93
|
|
| MD5 |
bfef3619a8c3ed6742742aaf083c5751
|
|
| BLAKE2b-256 |
dfec1ded9da420b82cb8fea2c980013121fb95349f59b236ecc9d9d5ed9226fd
|
Provenance
The following attestation bundles were made for remote_bash_tool-0.2.0.tar.gz:
Publisher:
publish.yml on blizhan/remote-bash-tool
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
remote_bash_tool-0.2.0.tar.gz -
Subject digest:
093b6183d8db866ca6f3eb69f3f56b6284ee0c8d3be320dd3b7a79cf6a567b93 - Sigstore transparency entry: 901939295
- Sigstore integration time:
-
Permalink:
blizhan/remote-bash-tool@11e7b904834c7180a3941c04ea5bc348feb6c811 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/blizhan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@11e7b904834c7180a3941c04ea5bc348feb6c811 -
Trigger Event:
push
-
Statement type:
File details
Details for the file remote_bash_tool-0.2.0-py3-none-any.whl.
File metadata
- Download URL: remote_bash_tool-0.2.0-py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b698637bcf7aa26abb28992802b42549b8621b939476d10af9c7850bd8930f03
|
|
| MD5 |
acb9c734f030327dec98f02537fc1aba
|
|
| BLAKE2b-256 |
db4fc6b7d37cfd32704cd732c408b255e72f70e96d78292ee5ccdce3c2f07806
|
Provenance
The following attestation bundles were made for remote_bash_tool-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on blizhan/remote-bash-tool
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
remote_bash_tool-0.2.0-py3-none-any.whl -
Subject digest:
b698637bcf7aa26abb28992802b42549b8621b939476d10af9c7850bd8930f03 - Sigstore transparency entry: 901939344
- Sigstore integration time:
-
Permalink:
blizhan/remote-bash-tool@11e7b904834c7180a3941c04ea5bc348feb6c811 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/blizhan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@11e7b904834c7180a3941c04ea5bc348feb6c811 -
Trigger Event:
push
-
Statement type: