Python中使用SSH需要用到OpenSSH,而OpenSSH依賴於paramiko模塊,而paramiko模塊又依賴於pycrypto模塊,因此要在Python中使用SSH。所以我們需要先安裝pycrypto工具,然后再安裝paramiko模塊才能使用。
首先要確保python安裝好,且環境變量設置好
paramiko模塊的使用請參考另一篇博文:http://blog.csdn.net/wangyuling1234567890/article/details/21656471
到下面這個網站下載編譯好的pycrypto(自己到官網下載編譯會比較麻煩,也可能過程中會出問題)
http://www.voidspace.org.uk/python/modules.shtml#pycrypto
安裝完成后執行如下則表示安裝成功:
注意大小寫,如果寫成小寫會出錯!!!
C:\Users\wangyuling>python Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import Crypto>>>>>>>>> import cryptoTraceback (most recent call last): File "<stdin>", line 1, in <module>ImportError: No module named crypto>>> 安裝paramiko:https://pypi.python.org/pypi/paramiko/1.7.7.1下載后解壓,然后命令行進入到解壓后的目錄,執行下面命令:python setup.py buildpython setup.py install
我的環境:
E:\python\paramiko-1.7.7.1>python setup.py build ... E:\python\paramiko-1.7.7.1>python setup.py install ...
安裝完成后執行如下則表示安裝成功:
E:\python\paramiko-1.7.7.1>python Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import paramiko >>>paramiko模塊的使用請參考另一篇博文:http://blog.csdn.net/wangyuling1234567890/article/details/21656471