Python 使用paramiko连接时 Oops, unhandled type 3 (‘unimplemented‘) 报错处理

下面的代码在连接一台 Dell iDRAC 时,会有 Oops, unhandled type 3 的报错,但连接其它服务器的BMC时正常的

>>> import paramiko
>>> client = paramiko.SSHClient()
>>> client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
>>> client.connect(hostname='x.x.x.x', port=22, username='xxxx', password='xxxxx', allow_agent=False)
>>> channel = client.invoke_shell()
Oops, unhandled type 3 ('unimplemented')
Exception (client): Invalid packet blocking

后面才知道可能设备需要模拟输入认证,改成下面的就可以了, 主要是使用了 Transport 来进行模拟

[root@h92 ~]# ./python/bin/python3
Python 3.6.8 (default, Nov 16 2020, 16:55:22)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>>
>>> import paramiko
>>> client = paramiko.SSHClient()
>>> client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
>>> transport = paramiko.Transport(('x.x.x.x', 22))
>>> transport.connect(username='xxxx')
>>> transport.auth_password('xxx',"xxxxxx")
['publickey', 'keyboard-interactive']
>>> transport.auth_interactive_dumb('xxx')
[]
>>> client._transport = transport
>>> channel = client.invoke_shell()
>>> channel.send('help')
4
>>> command_result = channel.recv(10240).decode("utf-8")
>>> print(command_result)
/admin1-> help
>>> channel.send('\n')
1
>>> command_result = channel.recv(10240).decode("utf-8")
>>> print(command_result)

[Usage]
    show   [<options>] [<target>] [<properties>]
           [<propertyname>== <propertyvalue>]
    set    [<options>] [<target>] <propertyname>=<value>
    cd     [<options>] [<target>]
    create [<options>] <target> [<property of new target>=<value>]
           [<property of new target>=<value>]
    delete [<options>] <target>
    exit   [<options>]
    reset  [<options>] [<target>]
    start  [<options>] [<target>]
    stop   [<options>] [<target>]
    version [<options>]
    help   [<options>] [<help topics>]
    load -source <URI> [<options>] [<target>]
    dump -destination <URI> [<options>] [<target>]

/admin1->
>>>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值