Paramiko: SSH and SCP in Python

Paramiko is a cute Python library that gives you cross platform SSH and SCP capabilities. On Linux it relies on OpenSSH and on Windows it uses Pageant (I assume it could be configured to use something else... didn't need to consider that).

Page Contents

Problems on Windows

At the time of writing this I was trying to use the Paramiko library on a Windows XP machine using Paramiko version 1.16.0. It wouldn't work giving the following error:

File "C:\...\paramiko\", line 162, in write
ctypes.windll.kernel32.RtlMoveMemory(dest, msg, length)
ValueError: Procedure probably called with too many arguments (4 bytes in excess)

After a bit of googling I found out that it has been fixed on the Paramiko mainline but hadn't made it into an available pip-installable distribution yet.

The fix is really easy. Find the file in your Python distro and make the changes described here. In summary, wherever you see a line reading "length = ctypes.wintypes.SIZE(n)", change it to "length = ctypes.c_size_t(n)".

NOTE: This now appears to have been fixed. On a newer system where the pip install downloaded v2.0.2 it has been fixed.