您好,登錄后才能下訂單哦!
name | ip |
---|---|
SUZ-SW-101 | 10.X.X.1 |
SUZ-SW-102 | 10.X.X.2 |
SUZ-SW-103 | 10.X.X.3 |
SUZ-SW-104 | 10.X.X.4 |
import xlrd
import paramiko
import time
def ssh_SW(name,ip):
now = time.strftime("%Y%m%d", time.localtime(time.time()))
trans = paramiko.Transport((ip, 22))
trans.connect(username='admin', password='passwd')
ssh = paramiko.SSHClient()
ssh._transport = trans
stdin, stdout, stderr = ssh.exec_command('save')
print(stdout.read().decode())
stdin, stdout, stderr = ssh.exec_command('tftp 10.x.x.100 put startup.cfg ' + name + '-' + now + '.cfg')
print(stdout.read().decode())
trans.close()
def main():
workbook = xlrd.open_workbook('./sw.xlsx')
sheet = workbook.sheet_by_name('Sheet1')
count = sheet.nrows
for i in range(count-1):
i = i + 1
rows = sheet.row_values(i)
name = rows[0]
ip = rows[1]
ssh_SW(name,ip)
if __name__=="__main__":
main()
paramiko詳解見(jiàn)以下鏈接
https://blog.csdn.net/appke846/article/details/80514024
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。