Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Create LinPyAuto.py#26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
AmirHoseinTangsiriNET wants to merge1 commit intoCiscoDevNet:master
base:master
Choose a base branch
Loading
fromAmirHoseinTangsiriNET:patch-2
Open
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 108 additions & 0 deletionsParmiko-Linux-Example/LinPyAuto.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
import paramiko

def Server1():
l_password = "Password"
l_host = "IP"
l_user = "UserName"
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(l_host, username=l_user, password=l_password)
transport = ssh.get_transport()
session = transport.open_session()
session.set_combine_stderr(True)
session.get_pty()
session.exec_command("ls")
stdin = session.makefile('wb', -1)
stdout = session.makefile('rb', -1)
stdin.write(l_password +'\n')
stdin.flush()
for line in stdout.read().splitlines():
print ('host: %s: %s' % (l_host, line))

#For Other Servers
def Server2():
l_password = "Password"
l_host = "IP"
l_user = "UserName"
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(l_host, username=l_user, password=l_password)
transport = ssh.get_transport()
session = transport.open_session()
session.set_combine_stderr(True)
session.get_pty()
session.exec_command("sudo brctl show")
stdin = session.makefile('wb', -1)
stdout = session.makefile('rb', -1)
stdin.write(l_password +'\n')
stdin.flush()
for line in stdout.read().splitlines():
print ('host: %s: %s' % (l_host, line))

#For Other Servers

def Server3():
l_password = "Password"
l_host = "IP"
l_user = "UserName"
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(l_host, username=l_user, password=l_password)
transport = ssh.get_transport()
session = transport.open_session()
session.set_combine_stderr(True)
session.get_pty()
session.exec_command("Command")
stdin = session.makefile('wb', -1)
stdout = session.makefile('rb', -1)
stdin.write(l_password +'\n')
stdin.flush()
for line in stdout.read().splitlines():
print ('host: %s: %s' % (l_host, line))


#For Other Servers

def Server4():
l_password = "Password"
l_host = "IP"
l_user = "UserName"
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(l_host, username=l_user, password=l_password)
transport = ssh.get_transport()
session = transport.open_session()
session.set_combine_stderr(True)
session.get_pty()
session.exec_command("Command")
stdin = session.makefile('wb', -1)
stdout = session.makefile('rb', -1)
stdin.write(l_password +'\n')
stdin.flush()
for line in stdout.read().splitlines():
print ('host: %s: %s' % (l_host, line))

def Server5():
l_password = "Password"
l_host = "IP"
l_user = "UserName"
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(l_host, username=l_user, password=l_password)
transport = ssh.get_transport()
session = transport.open_session()
session.set_combine_stderr(True)
session.get_pty()
session.exec_command("Command")
stdin = session.makefile('wb', -1)
stdout = session.makefile('rb', -1)
stdin.write(l_password +'\n')
stdin.flush()
for line in stdout.read().splitlines():
print ('host: %s: %s' % (l_host, line))

Server1()
#Server2()
#Server3()
#Server4()
#Server5()

[8]ページ先頭

©2009-2025 Movatter.jp