Learn How We Can Help You Keep Teleworkers Protected During the COVID-19 Crisis

Automation Scripts

Reply
Highlighted

Python Paramiko

Techie
Posts: 4
10783     0

Has anyone gotten a python paramiko script to connect and execute a command against a grid member?

 

My script can connect to sshd on Linux or other network appliances.

Highlighted

Re: Python Paramiko

Techie
Posts: 2
10784     0

I havent tried this yet, however we are looking at using ansible modules that are already out in the Galaxy repo to interact with our grid

Highlighted

Re: Python Paramiko

[ Edited ]
Techie
Posts: 1
10784     0

 

import paramiko

ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(hostname='192.168.10.10', username='ubuntu', key_filename='/home/ubuntu/.ssh/mykey.pem')

stdin, stdout, stderr = ssh.exec_command('lsb_release -a')

for line in stdout.read().splitlines():
    print(line)

ssh.close()

Using this for executing remote Bash Commands, can't rework it to grid member for last 2 days. Maybe someone can help here? don't want to start the new branch through.




best site to buy research paper

 

Highlighted

Re: Python Paramiko

Techie
Posts: 1
10784     0

Hi,

 

Below is my simple ssh() to execute a command on a grid member but doesn't work. It works on a cisco router or linux host, but won't work on Infoblox. Any idea?

 

 

def ssh(device, username, password):
     client = paramiko.SSHClient()
     client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
     client.connect(device, username=username, password=password)

     cmd = 'show status'
     stdin, stdout, stderr = client.exec_command(cmd)

     result = stdout.read()
     client.close()
     return result

 

 

 

Highlighted

Re: Python Paramiko

Adviser
Posts: 431
10784     0

What's the error you are seeing it might help?

Follow me on LinkedIn: https://www.linkedin.com/in/sifbaksh
Twitter: https://twitter.com/sifbaksh

www.sifbaksh.com
Showing results for 
Search instead for 
Do you mean 

Recommended for You