How to install paramiko (paramiko_scp)
Good day !
So you want to connect with SSH in python, or maybe upload files securely with SFTP from python? Paramiko will do the job.
There are two ways to install this, (i) from sources, (ii) with an online package via easy_install. But first let's gather the prerequisites.
Prerequisites - Ubuntu
Install openssh-server on ubuntu
$> sudo apt-get install openssh-server
$> sudo service ssh restart
setuptools:
$> sudo easy_install setuptools
Prerequisites - OSX
Install from sources pcre-8.31.tar.gz
Install from sources swig-2.0.7.tar.gz
setuptools:
$> sudo easy_install setuptools
Prerequisites - Windows
(i) Install python into C:\Python27
(ii) Add to path: c:\python27;c:\python27\Scripts;
(iii) Install setuptools : http://peak.telecommunity.com/dist/ez_setup.py
Run: python ez_setup.py
(iv) Install pcrypto .msi (32-bit or 64-bit *must* match python installation of 32/64-bit)
http://www.voidspace.org.uk/python/modules.shtml#pycrypto
(v) Optional: $>easy_install winpexpect
This allows you to socket-related-code that runs in windows as well. Otherwise the .select() function doesn't work.
Note: You might need MinGW or cygwin temporarily for the installation, then you can remove it. Please first try without it.
From sources or from existing package ?
If you are on OSX, the latest package that you will get dates back to 2008. That's too old and you will need to install from sources. At the time I am writing this the latest version is 1.7.7.2.
To install pre-built package (don't)
WARNING: Do not do this, at the time of writing, even if it works, you get a version that dates back to 2008 which is buggy.
Anyhow the syntax to issue is :
$> sudo easy_install paramiko
Build from sources
Do not checkout paramiko_scp from the Bazaar repository. This repository is old and hasn't been updated since 2008. You might be tempted to checkout the Bazaar repository because some documentation says so. Instead, fetch the latest sources from http://pypi.python.org/pypi/paramiko/
Extract and go to the directory, then build and install paramiko_scp:
$> sudo easy_install ./
or in windows: $> easy_install ./
NOTE: The ./ is important, it indicates easy_install to install the source code present in the current directory; it is thus important to also be in the correct directory 
Miscellaneous problem solving
To fix the following error:
{{{
To fix error: ImportError: No module named pkg_resources
}}}
Install ipython:
$> sudo easy_install ipython
WARNING: There are many places to find paramiko. Even newer version are missing some ssh keys and you might at some point stumble on the following error. This means you are using a too old version of paramiko, or unpatched :
{{{
ssh.connect(host, username=username, password=None, pkey=privkey, key_filename=None, timeout=6)
File "build/bdist.macosx-10.7-intel/egg/paramiko/client.py", line 315, in connect
File "build/bdist.macosx-10.7-intel/egg/paramiko/client.py", line 469, in _auth
paramiko.SSHException: Unknown private key cipher "AES-128-CBC"
}}}
Recent Comments