Home > Python > Install paramiko on linux without root access

Install paramiko on linux without root access


Install python paramiko module. This module requires the python-dev and pycrypto package. If you dont have root access to the system, then you can manage to add these modules to python as depicted below,




1) List the download url of python-dev packages, and then extract it to python-dev directory.


# apt-get --print-uris install python-dev -y|awk ' /http/ {print $1}'|cut -d\' -f2
# mkdir -p /home/username/python/{modules,custommodules}
# mkdir /home/username/python/modules/python-dev
# cd /home/username/python/modules
# wget http://us.archive.ubuntu.com/ubuntu/pool/main/p/python2.6/python2.6-dev_2.6.5-1ubuntu6_i386.deb
# wget http://us.archive.ubuntu.com/ubuntu/pool/main/p/python-defaults/python-dev_2.6.5-0ubuntu1_all.deb
# dpkg-deb -x python2.6-dev_2.6.5-1ubuntu6_i386.deb python-dev/
# dpkg-deb -x python-dev_2.6.5-0ubuntu1_all.deb python-dev/


Copy the development files of python from python-dev to source files directory of pycrypto-2.6 and use it for installing pycrypto. If you are not doing this then you will get an error like “error: Python.h: No such file or directory


# wget http://pypi.python.org/packages/source/p/pycrypto/pycrypto-2.6.tar.gz#md5=88dad0a270d1fe83a39e0467a66a22bb
# tar xzf pycrypto-2.6.tar.gz
# cd /home/username/python/modules/pycrypto-2.6
# cp -pr ../python-dev/usr/include/python2.6/* src/
# python setup.py install --prefix=/home/username/python/custommodules



2) Install paramiko


# cd /home/username/python/modules
# wget http://www.lag.net/paramiko/download/paramiko-
# tar xzf paramiko-
# python paramiko-  install --prefix=/home/username/python/custommodules


3) Now test whether python paramiko module is loaded or not


# python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) 
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path.append('/home/username/python/custommodules/lib/python2.6/site-packages')
>>> import paramiko
>>> ssh = paramiko.SSHClient()
>>> ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
>>> ssh.connect('',username='root',password='dK7:?Yjo')
>>> stdin, stdout, stderr = ssh.exec_command("ls /root")
>>> stdout.readlines()
['file1\n', '\\\n', 'ljsh\n', 'test\n', 'tmp\n']
>>> ssh.close()
>>> exit()



Hope this helps someone:)


Categories: Python
  1. Anonymous
    August 28, 2012 at 11:34 pm

    To append the custom python library path, you can add the following line ~/.bashrc file,

    export PYTHONPATH=/home/username/python/custommodules/lib/python2.6/site-packages

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: