paramiko / paramiko/paramiko

SSHException: Invalid packet blocking when using invoke_shell

Open
#1,438 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
9.9k
Forks
2.1k
PR merge metrics
No merged PRs in 30d

Description

The following code produces an exception in paramiko 2.4.2 on Xubuntu 18.04 x86-64, python 3.6.7

import paramiko
from paramiko.client import SSHClient
c = SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect('10.0.0.10', username='root', password='password')
x = c.invoke_shell()
x.exec_command('ls')
Traceback (most recent call last):
  File "/home/iling/.local/lib/python3.6/site-packages/paramiko/transport.py", line 1982, in run
    ptype, m = self.packetizer.read_message()
  File "/home/iling/.local/lib/python3.6/site-packages/paramiko/packet.py", line 451, in read_message
    raise SSHException("Invalid packet blocking")
paramiko.ssh_exception.SSHException: Invalid packet blocking

However, if I use send() and recv() instead of exec_command() then it works properly. I have tried many different hosts running different versions of different SSH servers (openssh, dropbear), but I still get this exception, so it is not a server issue. Some servers use bash for the shell, others use ash (busybox).

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the snippet with Paramiko 2.4.2, then inspect transport.py around Transport.run and packet.py around Packetizer.read_message, which appear in the traceback. Check how invoke_shell and exec_command interact and look for existing tests covering channel command execution; done means the reported exception is understood and the intended behavior has regression coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.