当前位置: 首页 > Skill >

huawei-cloud-ascend-remote-connect

huawei-cloud-ascend-remote-connect

huawei-cloud-ascend-remote-connect

为华为云 Ascend 设备提供临时 SSH 远程连接,支持动态输入主机/端口/用户名/密码(仅在内存中),磁盘管理,NPU 监控...

1.0.0 2026.11.17 594
获取Skill文件查看使用说明
作 者:沈知 许可证: 更新时间:2026.11.17
本文目录展开

Huawei Cloud Ascend Remote Connection

Overview

Provides temporary SSH remote connection capability for Huawei Cloud Ascend devices. Supports simultaneous connection to multiple machines. All sensitive operations (delete, modify, move, etc.) require user confirmation before execution. Passwords are only stored in memory and destroyed after session ends.

Architecture

System Architecture Diagram

┌─────────────────────────────────────────────────────────────────────┐
│                        User Interaction Layer                       │
│  ┌─────────────────────────────────────────────────────────────┐    │
│  │  Natural Language Commands / CLI Arguments                  │    │
│  │  (connect, execute, monitor, disconnect)                   │    │
│  └────────────────────────────┬────────────────────────────────┘    │
│                               │                                     │
│                               ▼                                     │
├────────────────────────────────┼─────────────────────────────────────┤
│                      Skill Core Components                          │
│  ┌─────────────────┐  ┌─────────────────┐  ┌─────────────────┐      │
│  │ Session Manager │←→│ Command Executor│←→│   SSH Client    │      │
│  │  - Connection   │  │  - NL Parsing   │  │  - paramiko     │      │
│  │  - Pooling      │  │  - Validation   │  │  - ControlMaster│      │
│  │  - Timeout Mgmt │  │  - Execution    │  │  - Key/Cert Auth│      │
│  └─────────────────┘  └─────────────────┘  └────────┬────────┘      │
│         │                      │                     │               │
│         │                      │                     ▼               │
│         │                      │         ┌─────────────────┐        │
│         │                      │         │ Command Validator│        │
│         │                      │         │  - Blocked Cmds  │        │
│         │                      │         │  - Confirm Req   │        │
│         │                      │         └─────────────────┘        │
│         │                      │                                     │
│         ▼                      ▼                                     │
├────────────────────────────────┼─────────────────────────────────────┤
│                    Huawei Cloud Ascend Infrastructure               │
│                          (Remote Target Servers)                    │
│  ┌─────────────────┐  ┌─────────────────┐  ┌─────────────────┐      │
│  │   Ascend NPU    │  │    OS Services  │  │    Containers   │      │
│  │  - npu-smi      │  │  - systemctl    │  │  - docker       │      │
│  │  - Driver       │  │  - journalctl   │  │  - k8s          │      │
│  │  - FW Upgrade   │  │  - Network Mgmt │  │  - Pods         │      │
│  └─────────────────┘  └─────────────────┘  └─────────────────┘      │
│                                                                      │
│  Data Flow: User → Skill → SSH Tunnel → Target Server → Response    │
└─────────────────────────────────────────────────────────────────────┘

Component Relationships

Component Responsibility Key Features
Session Manager Manage SSH connections Connection pooling, timeout management, lifecycle control
Command Executor Process user commands Natural language parsing, command routing, result formatting
SSH Client Establish secure tunnels paramiko integration, ControlMaster, authentication
Command Validator Security enforcement Blocked commands list, confirmation requirements

Cloud Service Integration

  • Ascend NPU Management: Direct access to npu-smi for monitoring and management
  • Huawei Cloud Infrastructure: Secure SSH access to cloud servers and containers
  • Security Compliance: Memory-only credential storage, session isolation

Prerequisites

System Requirements

  • Python 3.8+
  • paramiko >= 3.4.0

Environment Check

Prerequisite check: Python3 + paramiko required

python3 --version  # Python3 >= 3.8
python3 -c "import paramiko; print('OK')"  # SSH library

If not installed: pip3 install --user paramiko cryptography

Authentication

Security rules (must be followed):

  • Prohibited from reading, echoing, or printing password values
  • Prohibited from asking the user to input passwords directly in the conversation
  • Only allowed to read credentials from command line arguments

Parameter Confirmation

Input Parameters

Parameter Required Description
host Yes Target server IP address
port No SSH port (default: 22)
user Yes SSH username
password Yes SSH password

Parameter Validation

  • IP address format: IPv4 (e.g., 192.168.1.100)
  • Port range: 1-65535
  • Username: alphanumeric and underscore
  • Password: non-empty string

Confirmation Requirements

The following operations require explicit user confirmation:

  • Delete: rm, rmdir
  • Format: mkfs, fdisk -d, parted rm
  • Unmount: umount
  • Reboot: reboot, shutdown, init 6
  • Shutdown: poweroff, halt, init 0
  • User delete: userdel, groupdel
  • Permission change: chmod -R, chown -R

IAM Permission Policies

Ensure the target server has SSH service enabled and the provided credentials have appropriate permissions.

Minimum required permissions on target server:

  • SSH access (port 22 or custom)
  • Sudo privileges for system management operations

Core Workflow

Task 1: Establish SSH Connection

python3 scripts/main.py --host <ascend-server-ip> --port 22 --user root --password <your-password> --command "npu-smi info"

Task 2: Interactive Mode

python3 scripts/main.py

Usage Instructions

Connect to Ascend Server

SSH connect to 192.168.1.100 port 22 as root with password xxx

Execute Commands

NPU Monitoring

npu-smi info
Check NPU status
NPU health check

System Management

Check CPU and memory
df -h
top -bn1

Connection Management

Show current connections
Switch to 192.168.1.101
Disconnect SSH

Output Format

Standard Response Format

All command outputs follow a structured format:

┌─────────────────────────────────────────┐
│ Target: <host>:<port>                   │
│ Command: <executed-command>             │
│ Exit Code: <0-success/non-zero-fail>    │
├─────────────────────────────────────────┤
│ STDOUT:                                │
│ <command-output>                        │
├─────────────────────────────────────────┤
│ STDERR:                                 │
│ <error-output>                          │
├─────────────────────────────────────────┤
│ Duration: <seconds>s                     │
└─────────────────────────────────────────┘

Error Response Format

[ERROR] <error-code>
Message: <error-description>
Suggestion: <troubleshooting-tip>

Success Indicators

  • Exit Code: 0
  • STDOUT: Contains expected output
  • STDERR: Empty or contains only warnings

Verification Method

Basic Verification Steps

  1. Environment Check

    python3 --version  # Verify Python 3.8+
    python3 -c "import paramiko"  # Verify paramiko installed
    
  2. Connection Test

    python3 scripts/main.py --host <test-ip> --port 22 --user root --password <test-pwd> --command "echo test"
    
  3. NPU Monitoring Test

    python3 scripts/main.py --host <ascend-ip> --user root --password <pwd> --command "npu-smi info"
    

Expected Results

Test Case Expected Output
Environment check Python version >= 3.8, paramiko import success
Connection test Exit code 0, "test" in stdout
NPU info NPU device information displayed

See references/verification-method.md for detailed verification procedures.

Script Files

Entry File

  • main.py: Skill entry file (required)
    • Function: Provide interactive menu, unified entry point
    • Menu options:
      • Establish SSH connection
      • Execute commands
      • Disconnect

Core Scripts

  • executor.py: Command executor (main entry)

    • Function: Parse user input, dispatch commands to corresponding handlers
    • Core methods:
      • handle_command(text): Command dispatch entry
      • _connect(info): Establish SSH connection
      • _detect_disks(): Detect unmounted disks
      • _handle_auto_mount(text): Configure auto-mount on boot
      • _confirm_disk_merge(info): Disk merge confirmation
  • session_manager.py: Session manager

    • Function: Manage multiple concurrent SSH sessions
    • Core methods:
      • create_session(host, port, username, password): Create new session
      • execute_command(command): Execute command in active session
      • switch_session(host): Switch to specified host session
      • close_session(): Close current session
      • get_session_info(): Get all session information
  • ssh_client.py: SSH client

    • Function: Low-level SSH connection implementation, supports password and key authentication
    • Core methods:
      • connect(): Establish SSH connection
      • exec_command(command): Execute remote command
      • close(): Close connection
  • command_validator.py: Command validator

    • Function: Security layer, filter dangerous commands
    • Validation rules:
      • Blocklist: Direct block (e.g., fork bomb)
      • Sensitive: Require confirmation (e.g., rm -rf, reboot)
      • Allowlist: Direct execution (e.g., ls, cat, df)

Supported Features

NPU Management

  • NPU status monitoring (npu-smi)
  • NPU health check
  • NPU configuration viewing

Disk Management

  • Disk detection
  • LVM merging
  • Partition mounting
  • Auto-mount on boot
  • Disk health check
  • Free space check

System Management

  • CPU/Memory/Disk monitoring
  • System updates
  • User/permission management
  • Cron job management

Network Management

  • Port scanning
  • Firewall configuration
  • Route viewing
  • Network interface configuration
  • DNS troubleshooting

Container Management

  • Docker installation and management
  • Image management
  • Container management
  • Log viewing
  • Docker Compose operations

Security Management

  • Login auditing
  • SSH key management
  • High-risk command blocking

Log Management

  • System logs
  • Application log analysis
  • Error troubleshooting

File Operations

  • Upload/download
  • Copy/transfer
  • Change permissions
  • Create/delete

Connection Pool Management

Features

  • Connection Reuse: Reuse same connection for same target, avoid repeated handshakes
  • Auto Disconnect: Auto disconnect after 10 minutes idle (configurable)
  • Thread Safe: Support multi-thread concurrent access
  • Status Query: View connection pool status and idle time

Protection Mechanisms

  • Max Connections Limit: Default 50, supports multi-target machines
  • Request Rate Limiting: Default max 200 concurrent requests
  • Connection Timeout: Default 10 seconds
  • Execute Timeout: Default 60 seconds
  • Health Check: Check connection status every 30 seconds, auto disconnect bad connections
# Using connection pool
from ssh_client import get_pool

pool = get_pool()
result = pool.execute(conn_info, 'ls -la')

# View pool status (includes statistics)
status = pool.get_pool_status()
# {
#   'connections': [...],
#   'total_connections': 2,
#   'max_connections': 10,
#   'max_concurrent_requests': 5,
#   'statistics': {'total_requests': 100, 'failed_requests': 2, ...}
# }

# Configure protection parameters
pool.configure(
    max_connections=20,           # Max connections
    max_concurrent_requests=10,   # Max concurrent requests
    idle_timeout=300,             # Idle timeout (seconds)
    connect_timeout=15,           # Connection timeout (seconds)
    execute_timeout=120           # Execute timeout (seconds)
)

Multi-Machine Connection

Support simultaneous connection to multiple machines, distinguished by IP address:

SSH connect to 192.168.1.100 port 22 as root with password xxx
SSH connect to 192.168.1.101 port 2222 as admin with password yyy

Switch Target

Switch to 192.168.1.101

View Current Connections

View current connections

Security Mechanisms

Sensitive Operation Confirmation

The following operations require user confirmation:

  • Delete: rm, rmdir
  • Format: mkfs, fdisk -d, parted rm
  • Unmount: umount
  • Reboot: reboot, shutdown, init 6
  • Shutdown: poweroff, halt, init 0
  • User delete: userdel, groupdel
  • Permission change: chmod -R, chown -R

High-Risk Command Blocking

The following commands are blocked by default:

  • :(){ :|:& };: (fork bomb)
  • Direct disk formatting commands

Password Security

  • Passwords only stored in memory
  • Immediately cleared after session ends
  • Not written to any configuration file or log

Best Practices

Connection Management

  1. Reuse Connections: Connection pool automatically reuses existing connections
  2. Timeout Settings: Adjust timeouts based on network conditions
  3. Idle Timeout: Default 10 minutes; set shorter for frequent disconnects

Security Recommendations

  1. Use Key Authentication: Prefer SSH keys over passwords when possible
  2. Limit Permissions: Grant minimum sudo privileges needed
  3. Monitor Sessions: Regularly check active connections
  4. Log Auditing: Review login logs periodically

Performance Optimization

  1. Batch Commands: Group related commands to reduce connection overhead
  2. Connection Pool Tuning: Adjust pool size based on concurrent needs
  3. Command Timeout: Set appropriate timeout values for long-running commands

Notes

Security Warnings

⚠️ Credential Handling:

  • Never log or display passwords
  • Clear credentials from memory after use
  • Use SSH keys for production environments

⚠️ High-Risk Operations:

  • Always confirm destructive operations (rm, mkfs, reboot)
  • Blocked commands cannot be bypassed
  • Review security mechanisms before deployment

Common Issues

Issue Cause Solution
Connection timeout Network/firewall Check network connectivity
Authentication failed Wrong credentials Verify username/password
Command blocked Security policy Review command validator rules
Pool exhausted Too many connections Increase max_connections

Limitations

  • SSH password authentication only (no interactive password prompt)
  • Single-user session per connection
  • Maximum 50 concurrent connections (configurable)

Troubleshooting

Connection Failed

  • Check if IP address and port are correct
  • Check if firewall allows the port
  • Check if username and password are correct
  • Check if SSH service is running on target host

Command Execution Failed

  • Check if command syntax is correct
  • Check if there is an active connection
  • Check if command is blocked by security policy

Disk Merge Failed

  • Check if disk is occupied by other processes
  • Check if LVM tools are installed
  • Check if disk is already mounted

Directory Structure

huawei-cloud-ascend-remote-connect/
├── SKILL.md              # Skill definition entry file (required)
├── scripts/              # Scripts directory (required)
│   ├── __init__.py       # Module export
│   ├── main.py           # Skill entry script (required)
│   ├── executor.py       # Command executor
│   ├── session_manager.py # Session manager
│   ├── ssh_client.py     # SSH client implementation
│   └── command_validator.py # Command validator
└── references/           # Reference documentation directory
    ├── troubleshooting.md # Troubleshooting guide
    ├── verification-method.md # Verification steps
    └── iam-policies.md   # IAM policies

References

Document Description
references/troubleshooting.md Troubleshooting guide
references/verification-method.md Verification steps
scripts/main.py Main entry script

Author: huawei-cloud

相关文章

更多
AWS EC2 免费服务器创建与使用指南

本文介绍如何在 AWS 平台通过免费套餐(Free Tier)创建并管理 EC2 云服务器。内容涵盖个人账号注册流程、俄亥俄州区域选择、1核1G内存实例的配置步骤,以及通过密钥对进行 SSH 远程连接的方法。同时详细说明了计费规则,指出计时单位为小时,每月免费时长为 30 天,需留意流量限制及月末关机策略以避免产生费用。

2026.10.09 647
Skill 文件
  • SKILL.md
    • Huawei Cloud Ascend Remote Connection
    • Overview
    • Architecture
      • System Architecture Diagram
      • Component Relationships
      • Cloud Service Integration
    • Prerequisites
      • System Requirements
      • Environment Check
    • Authentication
    • Parameter Confirmation
      • Input Parameters
      • Parameter Validation
      • Confirmation Requirements
    • IAM Permission Policies
    • Core Workflow
      • Task 1: Establish SSH Connection
      • Task 2: Interactive Mode
    • Usage Instructions
      • Connect to Ascend Server
      • Execute Commands
        • NPU Monitoring
        • System Management
        • Connection Management
    • Output Format
      • Standard Response Format
      • Error Response Format
      • Success Indicators
    • Verification Method
      • Basic Verification Steps
      • Expected Results
    • Script Files
      • Entry File
      • Core Scripts
    • Supported Features
      • NPU Management
      • Disk Management
      • System Management
      • Network Management
      • Container Management
      • Security Management
      • Log Management
      • File Operations
    • Connection Pool Management
      • Features
      • Protection Mechanisms
    • Multi-Machine Connection
      • Switch Target
      • View Current Connections
    • Security Mechanisms
      • Sensitive Operation Confirmation
      • High-Risk Command Blocking
      • Password Security
    • Best Practices
      • Connection Management
      • Security Recommendations
      • Performance Optimization
    • Notes
      • Security Warnings
      • Common Issues
      • Limitations
    • Troubleshooting
      • Connection Failed
      • Command Execution Failed
      • Disk Merge Failed
    • Directory Structure
    • References
  • 项目或源文件

相关 Skill

更多
Media Cli Media Cli 单文件 Bash CLI,支持 SSH 远程连接,适用于 *arr 媒体栈。适合代理与媒体服务运行在不同机器上的场景(如 VPS 代理管理...)。
SSH 远程连接 SSH 远程连接 SSH 远程连接核心技能。涵盖安全远程访问、密钥管理、隧道转发和文件传输。触发词:SSH、远程连接、密钥、隧道、scp、sftp。
service-qa-coach service-qa-coach Review support quality for chat, email, phone, social DM, or marketplace service teams. Use when a team needs a QA scorecard, failure-mode analysis, coaching plan, calibration checklist, or service-improvement brief without live ticketing, CRM, or contact-center system access.
高中数学作业批改助手 高中数学作业批改助手 >图片识别 直接读取学生手写作答照片,识别公式、符号、步骤 🧮 自动推导 根据题目自动生成参考答案和评分细则,无需教师预设 📊 逐步给分 每个关键步骤独立评分,体现过程分 📝 结构化报告 输出含识别内容、参考答案、逐步评分、改进建议的完整报告 🗂 批量批改 支持一次性批改多道题,最终汇总得分表
Vibration Analysis Vibration Analysis 分析来自CMS趋势、RMS/峰值、频谱及SCADA报警的风机传动链(主轴、齿轮箱、发电机)振动数据。