SSH Command Executor
This skill allows you to execute SSH commands on remote servers securely. It supports both password and key-based authentication methods, making it versatile for various use cases.
Features
- - Authentication: Supports both password and key-based authentication.
- Command Execution: Execute any command on the remote server and retrieve the output.
- Error Handling: Provides detailed error messages for failed command executions.
- Logging: Logs all executed commands and their results for auditing purposes.
Prerequisites
- - SSH Client: Ensure you have an SSH client installed on your local machine.
- Remote Server Access: You must have access to the remote server with the necessary credentials.
- Python Environment: This skill is implemented in Python, so ensure you have Python installed on your local machine.
Usage
To execute a command on a remote server using password authentication:
python3 skills/sshexec/ssh_exec.py --host "remote-server.com" --user "username" --password "password" --command "ls -la"
To execute a command using key-based authentication:
python3 skills/sshexec/ssh_exec.py --host "remote-server.com" --user "username" --key "path/to/private/key" --command "ls -la"
Error Handling
The skill will provide detailed error messages if the command execution fails, such as authentication errors, connection issues, or command errors. All errors will be logged for further analysis.
Future Expansion
- - Support for executing multiple commands in a single session.
- Integration with task schedulers for automated command execution.
- Enhanced logging with timestamps and command output storage.
SSH命令执行器
该技能允许您在远程服务器上安全地执行SSH命令。它支持密码认证和密钥认证两种方式,适用于多种使用场景。
功能特点
- - 认证方式:支持密码认证和密钥认证。
- 命令执行:可在远程服务器上执行任意命令并获取输出结果。
- 错误处理:针对执行失败的命令提供详细的错误信息。
- 日志记录:记录所有已执行命令及其结果,便于审计追踪。
前置条件
- - SSH客户端:确保本地机器已安装SSH客户端。
- 远程服务器访问权限:必须拥有访问远程服务器的必要凭证。
- Python环境:该技能基于Python实现,请确保本地机器已安装Python。
使用方法
使用密码认证在远程服务器上执行命令:
bash
python3 skills/sshexec/ssh_exec.py --host remote-server.com --user username --password password --command ls -la
使用密钥认证执行命令:
bash
python3 skills/sshexec/ssh_exec.py --host remote-server.com --user username --key path/to/private/key --command ls -la
错误处理
当命令执行失败时,该技能将提供详细的错误信息,包括认证错误、连接问题或命令错误等。所有错误均会记录在日志中,便于后续分析。
未来扩展
- - 支持在单次会话中执行多个命令。
- 与任务调度器集成,实现自动化命令执行。
- 增强日志功能,添加时间戳和命令输出存储。