0

I am a beginner in python development. In fact , I want to make an ssh connection through a python code , do you have an idea?

Rich
  • 3,781
  • 5
  • 34
  • 56
ibtissem
  • 23
  • 1
  • 6
  • This could do with some editing - are you asking, is there a python library which can open (and interact with..?) an SSH connection? – Rich Mar 09 '16 at 13:19
  • There are several ways to do it. For help, use [google](https://www.google.com/search?q=python+ssh). It is one of the most helpful resources on the internet. – zondo Mar 09 '16 at 13:19
  • I try to install paramiko but i have an error , i search in net but no solution – ibtissem Mar 09 '16 at 14:06

1 Answers1

0

I'd suggest using fabric module. It's rather simply to use, for example:

from fabric.api import env, run

env.host_string = 'xxx.xxx.xxx.xxx'
env.user = 'username'
env.password = 'password'

run('ls -l')

That's just a simple example, but it should get you started.

kchomski
  • 2,872
  • 20
  • 31
  • I try to do this but i have this error : No module named fabic.api – ibtissem Mar 09 '16 at 13:59
  • @ibtissem: you have to install it first bacause it is not included in Python's standard library. Try `pip install -U fabric` at you terminal. – kchomski Mar 09 '16 at 14:09
  • Sorry but i have a problem with the command pip because i have a proxy and i'am in a work environnement – ibtissem Mar 09 '16 at 14:12
  • I try with paramiko but i have ap roblem "cannot import name "util" " ,have you any idea about this ? – ibtissem Mar 09 '16 at 14:15
  • You can try to use `pip` behind a proxy: http://stackoverflow.com/questions/14149422/using-pip-behind-a-proxy. Or you can download required packages manually from https://pypi.python.org. – kchomski Mar 09 '16 at 14:16
  • thanks , but could you tell me how to download required packages manually? – ibtissem Mar 09 '16 at 14:20