我把日志级别改成了debug,首先权限,命令都是无问题,权限给的最高,命令我手动ssh登录控制台都可正常显示,也不会报错,但是这个程序命令执行在交换机后台日志看只正确了执行quit这条命令,其余都未执行,程序日志如下:2025-07-15 14:21:27,593 - DEBUG - read_channel:
2025-07-15 14:21:29,594 - DEBUG - read_channel:
2025-07-15 14:21:29,594 - DEBUG - write_channel: b'quit\n'
2025-07-15 14:21:29,594 - DEBUG - EOF in transport thread
2025-07-15 14:21:29,595 - INFO - 172.17.201.28 不是已知汇聚交换机,作为最终设备
2025-07-15 14:21:29,608 - DEBUG - starting thread (client mode): 0x7a64f2f0
2025-07-15 14:21:29,608 - DEBUG - Local version/idstring: SSH-2.0-paramiko_3.5.1
2025-07-15 14:21:29,609 - DEBUG - Remote version/idstring: SSH-1.99-Comware-5.20
2025-07-15 14:21:29,609 - INFO - Connected (version 1.99, client Comware-5.20)
2025-07-15 14:21:29,631 - DEBUG - === Key exchange possibilities ===
2025-07-15 14:21:29,631 - DEBUG - kex algos: diffie-hellman-group-exchange-sha1, diffie-hellman-group14-sha1, diffie-hellman-group1-sha1
2025-07-15 14:21:29,631 - DEBUG - server key: ssh-rsa
2025-07-15 14:21:29,631 - DEBUG - client encrypt: aes128-cbc, 3des-cbc, des-cbc
2025-07-15 14:21:29,631 - DEBUG - server encrypt: aes128-cbc, 3des-cbc, des-cbc
2025-07-15 14:21:29,631 - DEBUG - client mac: hmac-sha1, hmac-sha1-96, hmac-md5, hmac-md5-96
2025-07-15 14:21:29,631 - DEBUG - server mac: hmac-sha1, hmac-sha1-96, hmac-md5, hmac-md5-96
2025-07-15 14:21:29,631 - DEBUG - client compress: none
2025-07-15 14:21:29,631 - DEBUG - server compress: none
2025-07-15 14:21:29,631 - DEBUG - client lang: <none>
2025-07-15 14:21:29,631 - DEBUG - server lang: <none>
2025-07-15 14:21:29,631 - DEBUG - kex follows: False
2025-07-15 14:21:29,631 - DEBUG - === Key exchange agreements ===
2025-07-15 14:21:29,631 - DEBUG - Kex: diffie-hellman-group-exchange-sha1
2025-07-15 14:21:29,631 - DEBUG - HostKey: ssh-rsa
2025-07-15 14:21:29,631 - DEBUG - Cipher: aes128-cbc
2025-07-15 14:21:29,631 - DEBUG - MAC: hmac-sha1
2025-07-15 14:21:29,632 - DEBUG - Compression: none
2025-07-15 14:21:29,632 - DEBUG - === End of kex handshake ===
2025-07-15 14:21:29,655 - DEBUG - Got server p (2048 bits)
2025-07-15 14:21:30,462 - DEBUG - kex engine KexGex specified hash_algo <built-in function openssl_sha1>
2025-07-15 14:21:30,462 - DEBUG - Switch to new keys ...
2025-07-15 14:21:30,463 - DEBUG - Adding ssh-rsa host key for 172.17.201.28: b'5e3ca5910d7cce29466ca9634fce6a23'
2025-07-15 14:21:30,486 - DEBUG - userauth is OK
2025-07-15 14:21:30,506 - INFO - Authentication (password) successful!
2025-07-15 14:21:30,507 - DEBUG - [chan 0] Max packet in: 32768 bytes
2025-07-15 14:21:30,528 - DEBUG - [chan 0] Max packet out: 32496 bytes
2025-07-15 14:21:30,528 - DEBUG - Secsh channel 0 opened.
2025-07-15 14:21:30,532 - DEBUG - [chan 0] Sesch channel 0 request ok
2025-07-15 14:21:30,536 - DEBUG - [chan 0] Sesch channel 0 request ok
2025-07-15 14:21:30,536 - DEBUG - write_channel: b'\n'
2025-07-15 14:21:30,638 - DEBUG - read_channel:
******************************************************************************
* Copyright (c) 2004-2013 Hangzhou H3C Tech. Co., Ltd. All rights reserved. *
* Without the owner's prior written consent, *
* no decompiling or reverse-engineering shall be allowed. *
******************************************************************************
<CDSL_SW201.28_LBG>
2025-07-15 14:21:30,638 - DEBUG - Pattern found: (to continue|[>\]])
******************************************************************************
* Copyright (c) 2004-2013 Hangzhou H3C Tech. Co., Ltd. All rights reserved. *
* Without the owner's prior written consent, *
* no decompiling or reverse-engineering shall be allowed. *
******************************************************************************
<CDSL_SW201.28_LBG>
2025-07-15 14:21:30,939 - DEBUG - read_channel:
<CDSL_SW201.28_LBG>
2025-07-15 14:21:30,939 - DEBUG - Clear buffer detects data in the channel
2025-07-15 14:21:31,540 - DEBUG - read_channel:
2025-07-15 14:21:31,540 - DEBUG - write_channel: b'\n'
2025-07-15 14:21:31,540 - DEBUG - read_channel:
2025-07-15 14:21:31,551 - DEBUG - read_channel:
<CDSL_SW201.28_LBG>
2025-07-15 14:21:31,551 - DEBUG -
Parenthesis found in pattern.
pattern: (>|\])
This can be problemtic when used in read_until_pattern().
You should ensure that you use either non-capture groups i.e. '(?:' or that the
parenthesis completely wrap the pattern '(pattern)'
2025-07-15 14:21:31,551 - DEBUG - Pattern found: (>|\])
<CDSL_SW201.28_LBG>
2025-07-15 14:21:31,852 - DEBUG - read_channel:
2025-07-15 14:21:31,852 - DEBUG - [find_prompt()]: prompt is <CDSL_SW201.28_LBG>
2025-07-15 14:21:31,852 - DEBUG - In disable_paging
2025-07-15 14:21:31,852 - DEBUG - Command: screen-length disable
2025-07-15 14:21:31,852 - DEBUG - write_channel: b'screen-length disable\n'
2025-07-15 14:21:31,852 - DEBUG - read_channel:
2025-07-15 14:21:31,863 - DEBUG - read_channel: s
2025-07-15 14:21:31,874 - DEBUG - read_channel:
2025-07-15 14:21:31,885 - DEBUG - read_channel: creen-length disable
2025-07-15 14:21:31,896 - DEBUG - read_channel:
2025-07-15 14:21:31,907 - DEBUG - read_channel:
^
% Unrecognized command found at '^' position.
<CDSL_SW201.28_LBG>
2025-07-15 14:21:31,907 - DEBUG - Pattern found: (CDSL_SW201\.28_LBG) screen-length disable
^
% Unrecognized command found at '^' position.
<CDSL_SW201.28_LBG
2025-07-15 14:21:31,907 - DEBUG - screen-length disable
^
% Unrecognized command found at '^' position.
<CDSL_SW201.28_LBG
2025-07-15 14:21:31,907 - DEBUG - Exiting disable_paging
2025-07-15 14:21:31,907 - INFO - 成功连接 172.17.201.28
2025-07-15 14:21:31,907 - DEBUG - write_channel: b'screen-length disable\n'
2025-07-15 14:21:32,008 - DEBUG - read_channel: screen-length disable
^
% Unrecognized command found at '^' position.
<CDSL_SW201.28_LBG>
2025-07-15 14:21:32,108 - DEBUG - read_channel:
2025-07-15 14:21:34,109 - DEBUG - read_channel:
2025-07-15 14:21:34,610 - DEBUG - write_channel: b'system-view\n'
2025-07-15 14:21:34,711 - DEBUG - read_channel: system-view
^
% Unrecognized command found at '^' position.
<CDSL_SW201.28_LBG>
2025-07-15 14:21:34,812 - DEBUG - read_channel:
2025-07-15 14:21:36,813 - DEBUG - read_channel:
2025-07-15 14:21:37,814 - INFO - 172.17.201.28 是 H3C V5 交换机,使用特殊绑定流程
2025-07-15 14:21:37,814 - DEBUG - write_channel: b'display mac-address 6c0b-5e47-7f89\n'
2025-07-15 14:21:37,915 - DEBUG - read_channel: display mac-address 6c0b-5e47-7f89
^
% Unrecognized command found at '^' position.
<CDSL_SW201.28_LBG>
2025-07-15 14:21:38,016 - DEBUG - read_channel:
2025-07-15 14:21:40,018 - DEBUG - read_channel:
2025-07-15 14:21:40,018 - INFO - MAC地址查询结果:
^
% Unrecognized command found at '^' position.
2025-07-15 14:21:40,018 - ERROR - 在 172.17.201.28 上未找到 MAC 6c0b-5e47-7f89 对应的端口
2025-07-15 14:21:40,019 - DEBUG - write_channel: b'\n'
2025-07-15 14:21:40,120 - DEBUG - read_channel:
<CDSL_SW201.28_LBG>
2025-07-15 14:21:40,221 - DEBUG - read_channel:
2025-07-15 14:21:42,222 - DEBUG - read_channel:
2025-07-15 14:21:42,222 - DEBUG - write_channel: b'quit\n'
2025-07-15 14:21:42,222 - DEBUG - EOF in transport thread
最新发布