paramiko error on Windows #193

Closed
hobbsd opened this Issue Aug 2, 2013 · 23 comments

Projects

None yet

10 participants

@hobbsd
hobbsd commented Aug 2, 2013

I'm using paramiko via Fabric. Version 1.10.1 works fine, but 1.11.0 failed with this traceback (just the paramiko part):

File "c:\python27\lib\site-packages\paramiko\client.py", line 342, in connect
self._auth(username, password, pkey, key_filenames, allow_agent, look_for_keys)
File "c:\python27\lib\site-packages\paramiko\client.py", line 474, in _auth
self._agent = Agent()
File "c:\python27\lib\site-packages\paramiko\agent.py", line 345, in init
self._connect(conn)
File "c:\python27\lib\site-packages\paramiko\agent.py", line 71, in _connect
ptype, result = self._send_message(chr(SSH2_AGENTC_REQUEST_IDENTITIES))
File "c:\python27\lib\site-packages\paramiko\agent.py", line 87, in _send_message
self._conn.send(struct.pack('>I', len(msg)) + msg)
File "c:\python27\lib\site-packages\paramiko\win_pageant.py", line 113, in send
self._response = _query_pageant(data)
File "c:\python27\lib\site-packages\paramiko\win_pageant.py", line 83, in _query_pageant
pymap.write(msg)
File "c:\python27\lib\site-packages\paramiko_winapi.py", line 133, in write
ctypes.windll.msvcrt.memcpy(self.view + self.pos, msg, len(msg))
ValueError: Procedure probably called with too many arguments (12 bytes in excess)

@MichaelHipp

I'm seeing this also running demo.py. Platform: Win7 x64, Python 2.7.5 x32.

demos>python demo.py
Hostname: lydia
*** Unable to open host keys file
*** WARNING: Unknown host key!
Username [michael]:
*** Caught exception: <type 'exceptions.ValueError'>: Procedure probably called with too many arguments (12 bytes in excess)
Traceback (most recent call last):
File "demo.py", line 154, in
agent_auth(t, username)
File "demo.py", line 42, in agent_auth
agent = paramiko.Agent()
File "C:\dev\virtenvs\yucca\lib\site-packages\paramiko\agent.py", line 345, in init
self._connect(conn)
File "C:\dev\virtenvs\yucca\lib\site-packages\paramiko\agent.py", line 71, in _connect
ptype, result = self._send_message(chr(SSH2_AGENTC_REQUEST_IDENTITIES))
File "C:\dev\virtenvs\yucca\lib\site-packages\paramiko\agent.py", line 87, in _send_message
self._conn.send(struct.pack('>I', len(msg)) + msg)
File "C:\dev\virtenvs\yucca\lib\site-packages\paramiko\win_pageant.py", line 113, in send
self._response = _query_pageant(data)
File "C:\dev\virtenvs\yucca\lib\site-packages\paramiko\win_pageant.py", line 83, in _query_pageant
pymap.write(msg)
File "C:\dev\virtenvs\yucca\lib\site-packages\paramiko_winapi.py", line 133, in write
ctypes.windll.msvcrt.memcpy(self.view + self.pos, msg, len(msg))
ValueError: Procedure probably called with too many arguments (12 bytes in excess)

@mpasternak

Same here, Windows 8 64-bit, Python 2.7.3 32-bit, paramiko 1.10.0

C:\Users\dotz\Desktop\django-bpp>fab download_dump
[X@Y] Executing task 'download_dump'
[X@Y] run: pg_dump Z | gzip > dump.gz
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\fabric\main.py", line 743, in main
    *args, **kwargs
  File "C:\Python27\lib\site-packages\fabric\tasks.py", line 368, in execute
    multiprocessing
  File "C:\Python27\lib\site-packages\fabric\tasks.py", line 264, in _execute
    return task.run(*args, **kwargs)
  File "C:\Python27\lib\site-packages\fabric\tasks.py", line 171, in run
    return self.wrapped(*args, **kwargs)
  File "C:\Python27\lib\site-packages\fabric\decorators.py", line 53, in inner_decorator
    return func(*args, **kwargs)
  File "C:\Users\dotz\Desktop\django-bpp\fabfile.py", line 16, in download_dump
    run("pg_dump Z | gzip > %s" % DUMP)
  File "C:\Python27\lib\site-packages\fabric\network.py", line 578, in host_prompting_wrapper
    return func(*args, **kwargs)
  File "C:\Python27\lib\site-packages\fabric\operations.py", line 1042, in run
    shell_escape=shell_escape)
  File "C:\Python27\lib\site-packages\fabric\operations.py", line 909, in _run_command
    channel=default_channel(), command=wrapped_command, pty=pty,
  File "C:\Python27\lib\site-packages\fabric\state.py", line 387, in default_channel
    chan = _open_session()
  File "C:\Python27\lib\site-packages\fabric\state.py", line 379, in _open_session
    return connections[env.host_string].get_transport().open_session()
  File "C:\Python27\lib\site-packages\fabric\network.py", line 118, in __getitem__
    self.connect(key)
  File "C:\Python27\lib\site-packages\fabric\network.py", line 110, in connect
    self[key] = connect(user, host, port, sock)
  File "C:\Python27\lib\site-packages\fabric\network.py", line 392, in connect
    sock=sock
  File "C:\Python27\lib\site-packages\paramiko\client.py", line 342, in connect
    self._auth(username, password, pkey, key_filenames, allow_agent, look_for_keys)
  File "C:\Python27\lib\site-packages\paramiko\client.py", line 474, in _auth
    self._agent = Agent()
  File "C:\Python27\lib\site-packages\paramiko\agent.py", line 345, in __init__
    self._connect(conn)
  File "C:\Python27\lib\site-packages\paramiko\agent.py", line 71, in _connect
    ptype, result = self._send_message(chr(SSH2_AGENTC_REQUEST_IDENTITIES))
  File "C:\Python27\lib\site-packages\paramiko\agent.py", line 87, in _send_message
    self._conn.send(struct.pack('>I', len(msg)) + msg)
  File "C:\Python27\lib\site-packages\paramiko\win_pageant.py", line 113, in send
    self._response = _query_pageant(data)
  File "C:\Python27\lib\site-packages\paramiko\win_pageant.py", line 83, in _query_pageant
    pymap.write(msg)
  File "C:\Python27\lib\site-packages\paramiko\_winapi.py", line 133, in write
    ctypes.windll.msvcrt.memcpy(self.view + self.pos, msg, len(msg))
ValueError: Procedure probably called with too many arguments (12 bytes in excess)
@mpasternak

I downgraded Paramiko to version 1.10.0 and it works fine. The software asks for remote host password instead of error now. And, even if I run SSH agent (to avoid password prompt), I still have this bug. Which means, it has nothing to do with actual password prompt.

@hobbsd
hobbsd commented Oct 9, 2013

Paramiko still crashes (with the same error as in previous posts) on Windows as of version 1.12.0. The last working version for me is 1.10.2.

@bitprophet
Member

I'm afraid I have no ability to troubleshoot on Windows but clearly 1.11 broke Windows support somewhere - if somebody can investigate & suggest a fix I'd be happy to test it on a POSIX platform (to ensure it still works there) & merge.

@akx akx added a commit to akx/paramiko that referenced this issue Oct 25, 2013
@akx akx Fix #193 (use RtlMoveMemory instead of msvcrt.memcpy) 7dfa239
@wkornewald

Everything works again with akx's fix. Tested on Windows 7 32-bit, Python 2.7.5.

@mpasternak

+1 for akx's fix, works for me too, Windows 8 64-bit, Python 2.7.5 32-bit, paramiko 1.12.0

@hobbsd
hobbsd commented Dec 21, 2013

It works for me on Win 7 64-bit, Python 2.7.5.

@Atheuz
Atheuz commented Dec 25, 2013

Experienced the same error on Windows 8.1 64 bit on Python 2.7.6. Tried upgrading to the latest paramiko but it made no difference. Used akx's fix and that seemed to work.

@akx
Contributor
akx commented Dec 25, 2013

It's unfortunate that @bitprophet hasn't been active regarding paramiko in a while...
I'm sure there are other PRs that could use merging too.

@nicktimko

Is there a timeline to review akx's PR? Would be nice to have a working copy in PyPI; it's a bit wonky to have a git package dependency for my app.

@bitprophet
Member

Hi! I am here, just been focusing on other things & busy/on vacation during the US winter holiday season.

My policy re: Windows is "as long as multiple users on multiple versions of the OS + Python are cool, I'm cool" so @akx's PR looks great already.

My only question is: can any of y'all (@akx @wkornewald @mpasternak @hobbsd @Atheuz @nicktimko) test Python 2.5 and/or 2.6 real quick? I noticed everybody's using 2.7 above, would love to verify this works prior to that as well.

If nobody can (do it / do it soon) then I'll just say good enough & merge/release. Thanks!

@akx
Contributor
akx commented Jan 20, 2014

Sure, good point. I'll give it a shot w/ Py2.5 and Py2.6 on Windows XP (since that's a VM I can spin up quickly).

@akx
Contributor
akx commented Jan 20, 2014

Here, @bitprophet -- it seems Paramiko's winapi is totally broken on Python 2.5: https://gist.github.com/akx/8528051

2.6 and 2.7 work with the PR.

@nicktimko

Identical results on Win 7 using 32-bit Pythons 2.5.4 and 2.6.6

@akx
Contributor
akx commented Jan 20, 2014

The above PR seems to fix the Py2.5 winapi regression.

@bitprophet
Member

I cherry-picked both of @akx's PRs into the 1.10 branch, made one more cleanup tweak, and am merging that back upwards towards master. This will mean the fix should apply to most modern release lines.

I'd like to snag a few more bugfixes before I release, so if y'all (@akx @wkornewald @mpasternak @hobbsd @Atheuz @nicktimko) have time to check out one of the 1.10/1.11/1.12/master branches and verify that the fix still works, that'd be awesome! Thanks again.

@hobbsd
hobbsd commented Jan 22, 2014

The 1.12 master branch works for me (Windows 7-64bit, Python 2.7 32bit).

@jaraco
Contributor
jaraco commented May 8, 2015

@akx Thanks for fixing this issue. I'm curious as to why I never encountered the error in my testing. Do you know under what circumstances the error occurs? Was the issue only on 32-bit Python perhaps (as I develop/test primarily on 64-bit Python)?

@alexeiramone

The 1.16.0 is not working for me (Windows 7-64bit, Python 2.7 32bit).

@jaraco
Contributor
jaraco commented Jan 29, 2016

@alexeiramone Same error as above?

@alexeiramone

Yes, I don't have the stack but the message was "ValueError: Procedure probably called with too many arguments (4 bytes in excess)". I had to downgrade it to 1.10.2 and then my fabric's fabfile run commands worked.

@jaraco
Contributor
jaraco commented Jan 30, 2016

@alexeiramone You're looking for #613, fixed in #619.

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