exscript ssh on python

送分小仙女□ 提交于 2019-12-08 06:19:27

The login function expects an Exscript.Account object. Load your username and password into an Account and pass that in.

from Exscript.protocols import SSH2
from Exscript import Account

account = Account('user', 'password')
conn = SSH2()
conn.connect('192.168.86.12')
conn.login(account)
# ...
conn.close()
from Exscript.util.interact import read_login
from Exscript.protocols import SSH2
from Exscript import Host, Account

account1 = Account('uname','pwd')
conn = SSH2()
conn.connect('192.168.86.12')
conn.login(account1)
conn.execute('conf t')
conn.execute('no ip default-gateway')
conn.execute('ip default-gateway 192.168.68.10')

print "Response was:", repr(conn.response)
conn.send('exit\r')
conn.close()
Haroon Butt

I am new in this stuff and getting lot of hard time in my job,hope you guys help in this.

While login in multi nodes insert a certain commands to reconfirm the status of links and this should be document in a "txt" file or "log" file for confirmation I reached till below

from Exscript.protocols import SSH2    
from Exscript.util.file import get_hosts_from_file    
from Exscript import Account

accounts = [Account('myuser', 'mypassword')]    
conn = SSH2()          
hosts = get_hosts_from_file('myhosts.txt') 

def do_something(job, host, conn):
    conn.execute('sh int description | i PE')

start(hosts, accounts, do_something)    
conn.send('exit\r')    
conn.close()
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!