New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxycommand fix #681

Closed
wants to merge 3 commits into
base: master
from

Conversation

Projects
None yet
9 participants
@radssh
Contributor

radssh commented Feb 7, 2016

Simple fix of using unbuffered subprocess.PIPE uncovered a trickier bug
where the lack of timeout on initial readline call would pull data from
the first real packet, throwing off subsequent reads.

Doesn’t seem necessary to preserve a read buffer across recv() calls,
especially if it isn’t implemented correctly.

radssh added some commits Aug 21, 2015

ProxyCommand fixes for Python3
Simple fix of using unbuffered subprocess.PIPE uncovered a trickier bug
where the lack of timeout on initial readline call would pull data from
the first real packet, throwing off subsequent reads.

Doesn’t seem necessary to preserve a read buffer across recv() calls,
especially if it isn’t implemented correctly.
@rsuciu-gsg

This comment has been minimized.

rsuciu-gsg commented Jul 7, 2016

Are there any updates on this?
I have also the same issue when running Python 3 (although it works fine in 2.7).

Thanks.

@ledil

This comment has been minimized.

ledil commented Jul 18, 2016

any news ? Ive got the same problem ...

@nvgoldin

This comment has been minimized.

nvgoldin commented Jul 18, 2016

same here.
any news?

@nvgoldin

This comment has been minimized.

nvgoldin commented Jul 18, 2016

Confirming this patch fixed the issue, however I have another issue now, not sure if its related:

  File ".../python3.5/site-packages/paramiko/transport.py", line 1550, in stop_thread
    and not self.sock._closed and not self.packetizer.closed
AttributeError: 'ProxyCommand' object has no attribute '_closed'

I think this was added recently to transport.py in: 0ebd247

            while (
                self.is_alive() and self is not threading.current_thread()
                and not self.sock._closed and not self.packetizer.closed
            ):
                self.join(0.1)
@bitprophet

This comment has been minimized.

Member

bitprophet commented Jul 20, 2016

@nvgoldin that secondary issue is #774, FYI.

I haven't had time to test this fix myself; if @ledil and @rsuciu-gsg can confirm @nvgoldin's assert that it fixes the issue for them, I may consider merging w/o self-testing. Thanks!

@catmeme

This comment has been minimized.

catmeme commented Jul 20, 2016

Verifying this PR resolved this issue for me as well. Thanks @radssh

@rsuciu-gsg

This comment has been minimized.

rsuciu-gsg commented Jul 21, 2016

Also works for me.

Thanks,
Ramona

On Wed, Jul 20, 2016 at 10:01 PM, catmeme notifications@github.com wrote:

Verifying this PR resolved this issue for me as well. Thanks @radssh
https://github.com/radssh


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#681 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ANb3XK5DaDNDaWdl-zHkhckRSQjeVYaTks5qXnB8gaJpZM4HVNHN
.

@bitprophet bitprophet added this to the 1.16.3 et al milestone Jul 21, 2016

@bitprophet

This comment has been minimized.

Member

bitprophet commented Jul 26, 2016

Thanks all. Merging on faith. Read the fix commit & commit message and squinted at the code real good...pretty sure I see why it's a good fix. Computers: difficult.

@miguelozu21

This comment has been minimized.

miguelozu21 commented Oct 17, 2017

hi, i have a related issue. can you help me?

DEBUG:paramiko.transport:starting thread (client mode): 0x291fcd0L
DEBUG:paramiko.transport:Local version/idstring: SSH-2.0-paramiko_2.3.1
ERROR:paramiko.transport:Exception: Error reading SSH protocol banner
ERROR:paramiko.transport:Traceback (most recent call last):
ERROR:paramiko.transport: File "/usr/lib/python2.7/site-packages/paramiko/transport.py", line 1854, in run
ERROR:paramiko.transport: self._check_banner()
ERROR:paramiko.transport: File "/usr/lib/python2.7/site-packages/paramiko/transport.py", line 2005, in _check_banner
ERROR:paramiko.transport: 'Error reading SSH protocol banner' + str(e)
ERROR:paramiko.transport:SSHException: Error reading SSH protocol banner
ERROR:paramiko.transport:
Traceback (most recent call last):
File "xxxx.py", line 19, in
ssh.connect(hostname = name, port = port ,username = user, sock=proxy, password=None,key_filename = key_file, banner_timeout=None, timeout = 60)
File "/usr/lib/python2.7/site-packages/paramiko/client.py", line 385, in connect
t.start_client(timeout=timeout)
File "/usr/lib/python2.7/site-packages/paramiko/transport.py", line 543, in start_client
raise e
paramiko.ssh_exception.SSHException: Error reading SSH protocol banner

@yang-dev

This comment has been minimized.

yang-dev commented Mar 19, 2018

Trying to netconf on tcp/22 through ProxyCommand, still running into this issue with paramiko 2.4.1 (already have c638ecf), Python 3.6.4.

ERROR:ncclient.transport.ssh:Exception: Error reading SSH protocol banner due to _read_timeout()

@cndcourt

This comment has been minimized.

cndcourt commented Mar 27, 2018

Hi - I have encountered this with python 2.7.10. Is there a workaround or fix? Sorry - but reading this trail I couldn't see a clear step to take to get this working. Here is what I'm trying to do.

The setup is a pure key setup - not using user/password. I can do the proxy manually
with ssh.
Thanks for any help. /best Don

proxy='130.35.42.7'
proxy_command = 'ssh -q -W %h:%p {}'.format(proxy)
proxy = paramiko.ProxyCommand(proxy_command)

client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(host, sock=proxy)

stdin, stdout, stderr = client.exec_command('uname -a')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment