scriptd允许您通过http api安全地执行一组预配置的脚本或可执行文件,而不公开终端访问,而且几乎没有配置。
scriptd的Python项目详细描述
脚本
scriptd允许您通过http api安全地执行一组预配置的脚本或可执行文件,而不公开终端访问,而且几乎没有配置。
scriptd是为不需要直接ssh时的远程作业自动化而设计的,它可以帮助您处理开发服务器位于防火墙后面或公司的安全策略禁止直接ssh访问的情况。将代码更新/构建/部署命令作为脚本写下来,就可以只使用http访问了。不,您不会将服务器暴露于代码注入:只允许运行预配置的脚本。
功能
- 将预配置脚本设置为用于远程作业自动化的http api。
- 几乎为零的配置:一个包含脚本的工作目录和一个密钥,仅此而已。
- 没有终端暴露:scriptd不运行来自客户端请求的任何代码或参数,只运行预配置的脚本。没有代码注入。
- 安全:使用AES-256-GCM进行加密和身份验证。
用法
服务器
scriptd [-h] [-H HOST] [-p PORT] [-k KEY | --key-file KEY_FILE] [-d DIR]
optional arguments:
-h, --help show this help message and exit
-H HOST, --host HOST Host name to listen on, default: 0.0.0.0
-p PORT, --port PORT Port to listen on, default: 8182
-k KEY, --key KEY Authentication key, default: empty
--key-file KEY_FILE Authentication key file. Key will be derived from its hash.
-d DIR, --dir DIR Working directory, default: current dir
客户
scriptc [-h] [-H HOST] [-p PORT] [-k KEY | --key-file KEY_FILE] command
positional arguments:
command Name of the script to run on server
optional arguments:
-h, --help show this help message and exit
-H HOST, --host HOST Server ip or name, default: 127.0.0.1
-p PORT, --port PORT Server port, default: 8182
-k KEY, --key KEY Authentication key, default: empty
--key-file KEY_FILE Authentication key file. Key will be derived from its hash.
示例用法
在服务器上,将脚本放在名为~/scriptd_home
的目录中。强烈建议您将此目录及其下的任何文件仅允许自己访问。
准备用作密钥的任意大小的密钥文件。将其命名为~/scriptd_home/key
,并将其放在客户端和服务器上。
运行scriptd --key-file ~/scriptd_home/key -d ~/scriptd_home
启动服务器。
现在,您可以使用以下命令从客户端远程调用scriptd_home
中的脚本:
scriptc -H <your-server> --key-file <key-file-path> <script-name>
脚本将从服务器上的~/scriptd_home
调用。调用脚本的stdout和stderr都将被加密发送到客户端。
安装
要安装scriptd,只需运行:
pip install -U scriptd
要安装到unix全局python环境,请使用
sudo -H pip install -U scriptd