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
Environment Check
python3 --version # Verify Python 3.8+
python3 -c "import paramiko" # Verify paramiko installed
Connection Test
python3 scripts/main.py --host <test-ip> --port 22 --user root --password <test-pwd> --command "echo test"
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
- Reuse Connections: Connection pool automatically reuses existing connections
- Timeout Settings: Adjust timeouts based on network conditions
- Idle Timeout: Default 10 minutes; set shorter for frequent disconnects
Security Recommendations
- Use Key Authentication: Prefer SSH keys over passwords when possible
- Limit Permissions: Grant minimum sudo privileges needed
- Monitor Sessions: Regularly check active connections
- Log Auditing: Review login logs periodically
Performance Optimization
- Batch Commands: Group related commands to reduce connection overhead
- Connection Pool Tuning: Adjust pool size based on concurrent needs
- 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
1---
2name: huawei-cloud-ascend-remote-connect
3description: |
4 Provides temporary SSH remote connection for Huawei Cloud Ascend devices with dynamic host/port/user/password input (in-memory only), disk management, NPU monitoring, container management, security auditing and log analysis; sensitive operations require user confirmation before execution
5 Use this skillthis skill to remotely connect to Ascend servers, monitor NPU health, manage disks/LVM, or troubleshoot Ascend devices.
6 Triggerer words: SSH, remote, Ascend, NPU, 远程连接, 昇腾, NPU监控
7version: 1.0.0
8tags: [huawei-cloud, ascend, npu, ssh, remote]
9allowed-tools:
10 - python3
11 - bash
12 - ssh
13---
14
15# Huawei Cloud Ascend Remote Connection
16
17## Overview
18
19Provides 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.
20
21## Architecture
22
23### System Architecture Diagram
24
25```
26┌─────────────────────────────────────────────────────────────────────┐
27│ User Interaction Layer │
28│ ┌─────────────────────────────────────────────────────────────┐ │
29│ │ Natural Language Commands / CLI Arguments │ │
30│ │ (connect, execute, monitor, disconnect) │ │
31│ └────────────────────────────┬────────────────────────────────┘ │
32│ │ │
33│ ▼ │
34├────────────────────────────────┼─────────────────────────────────────┤
35│ Skill Core Components │
36│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │
37│ │ Session Manager │←→│ Command Executor│←→│ SSH Client │ │
38│ │ - Connection │ │ - NL Parsing │ │ - paramiko │ │
39│ │ - Pooling │ │ - Validation │ │ - ControlMaster│ │
40│ │ - Timeout Mgmt │ │ - Execution │ │ - Key/Cert Auth│ │
41│ └─────────────────┘ └─────────────────┘ └────────┬────────┘ │
42│ │ │ │ │
43│ │ │ ▼ │
44│ │ │ ┌─────────────────┐ │
45│ │ │ │ Command Validator│ │
46│ │ │ │ - Blocked Cmds │ │
47│ │ │ │ - Confirm Req │ │
48│ │ │ └─────────────────┘ │
49│ │ │ │
50│ ▼ ▼ │
51├────────────────────────────────┼─────────────────────────────────────┤
52│ Huawei Cloud Ascend Infrastructure │
53│ (Remote Target Servers) │
54│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │
55│ │ Ascend NPU │ │ OS Services │ │ Containers │ │
56│ │ - npu-smi │ │ - systemctl │ │ - docker │ │
57│ │ - Driver │ │ - journalctl │ │ - k8s │ │
58│ │ - FW Upgrade │ │ - Network Mgmt │ │ - Pods │ │
59│ └─────────────────┘ └─────────────────┘ └─────────────────┘ │
60│ │
61│ Data Flow: User → Skill → SSH Tunnel → Target Server → Response │
62└─────────────────────────────────────────────────────────────────────┘
63```
64
65### Component Relationships
66
67| Component | Responsibility | Key Features |
68|-----------|----------------|--------------|
69| **Session Manager** | Manage SSH connections | Connection pooling, timeout management, lifecycle control |
70| **Command Executor** | Process user commands | Natural language parsing, command routing, result formatting |
71| **SSH Client** | Establish secure tunnels | paramiko integration, ControlMaster, authentication |
72| **Command Validator** | Security enforcement | Blocked commands list, confirmation requirements |
73
74### Cloud Service Integration
75
76- **Ascend NPU Management**: Direct access to npu-smi for monitoring and management
77- **Huawei Cloud Infrastructure**: Secure SSH access to cloud servers and containers
78- **Security Compliance**: Memory-only credential storage, session isolation
79
80## Prerequisites
81
82### System Requirements
83
84- Python 3.8+
85- paramiko >= 3.4.0
86
87### Environment Check
88
89> **Prerequisite check: Python3 + paramiko required**
90> ```bash
91> python3 --version # Python3 >= 3.8
92> python3 -c "import paramiko; print('OK')" # SSH library
93> ```
94> If not installed: `pip3 install --user paramiko cryptography`
95
96## Authentication
97
98> **Security rules (must be followed):**
99> - **Prohibited** from reading, echoing, or printing password values
100> - **Prohibited** from asking the user to input passwords directly in the conversation
101> - **Only allowed** to read credentials from command line arguments
102
103## Parameter Confirmation
104
105### Input Parameters
106
107| Parameter | Required | Description |
108|-----------|----------|-------------|
109| host | Yes | Target server IP address |
110| port | No | SSH port (default: 22) |
111| user | Yes | SSH username |
112| password | Yes | SSH password |
113
114### Parameter Validation
115
116- IP address format: IPv4 (e.g., 192.168.1.100)
117- Port range: 1-65535
118- Username: alphanumeric and underscore
119- Password: non-empty string
120
121### Confirmation Requirements
122
123The following operations require explicit user confirmation:
124- Delete: rm, rmdir
125- Format: mkfs, fdisk -d, parted rm
126- Unmount: umount
127- Reboot: reboot, shutdown, init 6
128- Shutdown: poweroff, halt, init 0
129- User delete: userdel, groupdel
130- Permission change: chmod -R, chown -R
131
132## IAM Permission Policies
133
134Ensure the target server has SSH service enabled and the provided credentials have appropriate permissions.
135
136**Minimum required permissions on target server:**
137- SSH access (port 22 or custom)
138- Sudo privileges for system management operations
139
140## Core Workflow
141
142### Task 1: Establish SSH Connection
143
144```bash
145python3 scripts/main.py --host <ascend-server-ip> --port 22 --user root --password <your-password> --command "npu-smi info"
146```
147
148### Task 2: Interactive Mode
149
150```bash
151python3 scripts/main.py
152```
153
154## Usage Instructions
155
156### Connect to Ascend Server
157
158```
159SSH connect to 192.168.1.100 port 22 as root with password xxx
160```
161
162### Execute Commands
163
164#### NPU Monitoring
165```
166npu-smi info
167Check NPU status
168NPU health check
169```
170
171#### System Management
172```
173Check CPU and memory
174df -h
175top -bn1
176```
177
178#### Connection Management
179```
180Show current connections
181Switch to 192.168.1.101
182Disconnect SSH
183```
184
185---
186
187## Output Format
188
189### Standard Response Format
190
191All command outputs follow a structured format:
192
193```
194┌─────────────────────────────────────────┐
195│ Target: <host>:<port> │
196│ Command: <executed-command> │
197│ Exit Code: <0-success/non-zero-fail> │
198├─────────────────────────────────────────┤
199│ STDOUT: │
200│ <command-output> │
201├─────────────────────────────────────────┤
202│ STDERR: │
203│ <error-output> │
204├─────────────────────────────────────────┤
205│ Duration: <seconds>s │
206└─────────────────────────────────────────┘
207```
208
209### Error Response Format
210
211```
212[ERROR] <error-code>
213Message: <error-description>
214Suggestion: <troubleshooting-tip>
215```
216
217### Success Indicators
218
219- Exit Code: 0
220- STDOUT: Contains expected output
221- STDERR: Empty or contains only warnings
222
223---
224
225## Verification Method
226
227### Basic Verification Steps
228
2291. **Environment Check**
230 ```bash
231 python3 --version # Verify Python 3.8+
232 python3 -c "import paramiko" # Verify paramiko installed
233 ```
234
2352. **Connection Test**
236 ```bash
237 python3 scripts/main.py --host <test-ip> --port 22 --user root --password <test-pwd> --command "echo test"
238 ```
239
2403. **NPU Monitoring Test**
241 ```bash
242 python3 scripts/main.py --host <ascend-ip> --user root --password <pwd> --command "npu-smi info"
243 ```
244
245### Expected Results
246
247| Test Case | Expected Output |
248|-----------|----------------|
249| Environment check | Python version >= 3.8, paramiko import success |
250| Connection test | Exit code 0, "test" in stdout |
251| NPU info | NPU device information displayed |
252
253See [references/verification-method.md](references/verification-method.md) for detailed verification procedures.
254
255---
256
257## Script Files
258
259### Entry File
260
261- **main.py**: Skill entry file (required)
262 - Function: Provide interactive menu, unified entry point
263 - Menu options:
264 - Establish SSH connection
265 - Execute commands
266 - Disconnect
267
268### Core Scripts
269
270- **executor.py**: Command executor (main entry)
271 - Function: Parse user input, dispatch commands to corresponding handlers
272 - Core methods:
273 - `handle_command(text)`: Command dispatch entry
274 - `_connect(info)`: Establish SSH connection
275 - `_detect_disks()`: Detect unmounted disks
276 - `_handle_auto_mount(text)`: Configure auto-mount on boot
277 - `_confirm_disk_merge(info)`: Disk merge confirmation
278
279- **session_manager.py**: Session manager
280 - Function: Manage multiple concurrent SSH sessions
281 - Core methods:
282 - `create_session(host, port, username, password)`: Create new session
283 - `execute_command(command)`: Execute command in active session
284 - `switch_session(host)`: Switch to specified host session
285 - `close_session()`: Close current session
286 - `get_session_info()`: Get all session information
287
288- **ssh_client.py**: SSH client
289 - Function: Low-level SSH connection implementation, supports password and key authentication
290 - Core methods:
291 - `connect()`: Establish SSH connection
292 - `exec_command(command)`: Execute remote command
293 - `close()`: Close connection
294
295- **command_validator.py**: Command validator
296 - Function: Security layer, filter dangerous commands
297 - Validation rules:
298 - Blocklist: Direct block (e.g., fork bomb)
299 - Sensitive: Require confirmation (e.g., rm -rf, reboot)
300 - Allowlist: Direct execution (e.g., ls, cat, df)
301
302---
303
304## Supported Features
305
306### NPU Management
307- NPU status monitoring (npu-smi)
308- NPU health check
309- NPU configuration viewing
310
311### Disk Management
312- Disk detection
313- LVM merging
314- Partition mounting
315- Auto-mount on boot
316- Disk health check
317- Free space check
318
319### System Management
320- CPU/Memory/Disk monitoring
321- System updates
322- User/permission management
323- Cron job management
324
325### Network Management
326- Port scanning
327- Firewall configuration
328- Route viewing
329- Network interface configuration
330- DNS troubleshooting
331
332### Container Management
333- Docker installation and management
334- Image management
335- Container management
336- Log viewing
337- Docker Compose operations
338
339### Security Management
340- Login auditing
341- SSH key management
342- High-risk command blocking
343
344### Log Management
345- System logs
346- Application log analysis
347- Error troubleshooting
348
349### File Operations
350- Upload/download
351- Copy/transfer
352- Change permissions
353- Create/delete
354
355---
356
357## Connection Pool Management
358
359### Features
360- **Connection Reuse**: Reuse same connection for same target, avoid repeated handshakes
361- **Auto Disconnect**: Auto disconnect after 10 minutes idle (configurable)
362- **Thread Safe**: Support multi-thread concurrent access
363- **Status Query**: View connection pool status and idle time
364
365### Protection Mechanisms
366- **Max Connections Limit**: Default 50, supports multi-target machines
367- **Request Rate Limiting**: Default max 200 concurrent requests
368- **Connection Timeout**: Default 10 seconds
369- **Execute Timeout**: Default 60 seconds
370- **Health Check**: Check connection status every 30 seconds, auto disconnect bad connections
371
372```python
373# Using connection pool
374from ssh_client import get_pool
375
376pool = get_pool()
377result = pool.execute(conn_info, 'ls -la')
378
379# View pool status (includes statistics)
380status = pool.get_pool_status()
381# {
382# 'connections': [...],
383# 'total_connections': 2,
384# 'max_connections': 10,
385# 'max_concurrent_requests': 5,
386# 'statistics': {'total_requests': 100, 'failed_requests': 2, ...}
387# }
388
389# Configure protection parameters
390pool.configure(
391 max_connections=20, # Max connections
392 max_concurrent_requests=10, # Max concurrent requests
393 idle_timeout=300, # Idle timeout (seconds)
394 connect_timeout=15, # Connection timeout (seconds)
395 execute_timeout=120 # Execute timeout (seconds)
396)
397```
398
399---
400
401## Multi-Machine Connection
402
403Support simultaneous connection to multiple machines, distinguished by IP address:
404
405```
406SSH connect to 192.168.1.100 port 22 as root with password xxx
407SSH connect to 192.168.1.101 port 2222 as admin with password yyy
408```
409
410### Switch Target
411```
412Switch to 192.168.1.101
413```
414
415### View Current Connections
416```
417View current connections
418```
419
420---
421
422## Security Mechanisms
423
424### Sensitive Operation Confirmation
425The following operations require user confirmation:
426- Delete: rm, rmdir
427- Format: mkfs, fdisk -d, parted rm
428- Unmount: umount
429- Reboot: reboot, shutdown, init 6
430- Shutdown: poweroff, halt, init 0
431- User delete: userdel, groupdel
432- Permission change: chmod -R, chown -R
433
434### High-Risk Command Blocking
435The following commands are blocked by default:
436- `:(){ :|:& };:` (fork bomb)
437- Direct disk formatting commands
438
439### Password Security
440- Passwords only stored in memory
441- Immediately cleared after session ends
442- Not written to any configuration file or log
443
444---
445
446## Best Practices
447
448### Connection Management
449
4501. **Reuse Connections**: Connection pool automatically reuses existing connections
4512. **Timeout Settings**: Adjust timeouts based on network conditions
4523. **Idle Timeout**: Default 10 minutes; set shorter for frequent disconnects
453
454### Security Recommendations
455
4561. **Use Key Authentication**: Prefer SSH keys over passwords when possible
4572. **Limit Permissions**: Grant minimum sudo privileges needed
4583. **Monitor Sessions**: Regularly check active connections
4594. **Log Auditing**: Review login logs periodically
460
461### Performance Optimization
462
4631. **Batch Commands**: Group related commands to reduce connection overhead
4642. **Connection Pool Tuning**: Adjust pool size based on concurrent needs
4653. **Command Timeout**: Set appropriate timeout values for long-running commands
466
467---
468
469## Notes
470
471### Security Warnings
472
473⚠️ **Credential Handling**:
474- Never log or display passwords
475- Clear credentials from memory after use
476- Use SSH keys for production environments
477
478⚠️ **High-Risk Operations**:
479- Always confirm destructive operations (rm, mkfs, reboot)
480- Blocked commands cannot be bypassed
481- Review security mechanisms before deployment
482
483### Common Issues
484
485| Issue | Cause | Solution |
486|-------|-------|----------|
487| Connection timeout | Network/firewall | Check network connectivity |
488| Authentication failed | Wrong credentials | Verify username/password |
489| Command blocked | Security policy | Review command validator rules |
490| Pool exhausted | Too many connections | Increase max_connections |
491
492### Limitations
493
494- SSH password authentication only (no interactive password prompt)
495- Single-user session per connection
496- Maximum 50 concurrent connections (configurable)
497
498---
499
500## Troubleshooting
501
502### Connection Failed
503- Check if IP address and port are correct
504- Check if firewall allows the port
505- Check if username and password are correct
506- Check if SSH service is running on target host
507
508### Command Execution Failed
509- Check if command syntax is correct
510- Check if there is an active connection
511- Check if command is blocked by security policy
512
513### Disk Merge Failed
514- Check if disk is occupied by other processes
515- Check if LVM tools are installed
516- Check if disk is already mounted
517
518---
519
520## Directory Structure
521
522```
523huawei-cloud-ascend-remote-connect/
524├── SKILL.md # Skill definition entry file (required)
525├── scripts/ # Scripts directory (required)
526│ ├── __init__.py # Module export
527│ ├── main.py # Skill entry script (required)
528│ ├── executor.py # Command executor
529│ ├── session_manager.py # Session manager
530│ ├── ssh_client.py # SSH client implementation
531│ └── command_validator.py # Command validator
532└── references/ # Reference documentation directory
533 ├── troubleshooting.md # Troubleshooting guide
534 ├── verification-method.md # Verification steps
535 └── iam-policies.md # IAM policies
536```
537
538---
539
540## References
541
542| Document | Description |
543|----------|-------------|
544| [references/troubleshooting.md](references/troubleshooting.md) | Troubleshooting guide |
545| [references/verification-method.md](references/verification-method.md) | Verification steps |
546| [scripts/main.py](scripts/main.py) | Main entry script |
547
548**Author**: huawei-cloud