So this one had my head scratching not because the script was too complex , but the overall effort to run the script.
Again as i am new to python it took a while to get on with installing the correct packages and loading the right binaries.
so i will go step by step first on what is needed to run the ssh script in python 2.7
step1: installing the paramiko package
go to this link and download the paramiko package and unzip it in the python 2.7 folder
https://pypi.python.org/pypi/paramiko/1.14.0
now install it as show below
now install it as show below
step4: so finally the script
import paramiko
import sys
import os
dssh = paramiko.SSHClient()
dssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
dssh.connect('10.95.34.104',port=22, username='admin', password='Cisc0123')
dssh.exec_command('term len 0')
stdin, stdout, stderr = dssh.exec_command('sh ver')
a= stdout.read()
print a
f = open('testing.txt', 'a')
f.write(a)
f.close()
dssh.close()
Again as i am new to python it took a while to get on with installing the correct packages and loading the right binaries.
so i will go step by step first on what is needed to run the ssh script in python 2.7
step1: installing the paramiko package
go to this link and download the paramiko package and unzip it in the python 2.7 folder
https://pypi.python.org/pypi/paramiko/1.14.0
now install it as show below
step2: intalling the ecdsa0.11 package
go to this link and download the ecdsa0.11 package and unzip it in the python 2.7 folder
now install it as show below
step3: download the relevant pre built pycrypto binaries for windows machine from link below
step4: so finally the script
import paramiko
import sys
import os
dssh = paramiko.SSHClient()
dssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
dssh.connect('10.95.34.104',port=22, username='admin', password='Cisc0123')
dssh.exec_command('term len 0')
stdin, stdout, stderr = dssh.exec_command('sh ver')
a= stdout.read()
print a
f = open('testing.txt', 'a')
f.write(a)
f.close()
dssh.close()
No comments:
Post a Comment