We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I have use following code for ssh connection to HP Procurve switch
import paramiko
def readAndConnect(user, password, tftpRoot, tftp, hostFile, continueBannerSwitchListExist="no"):
#open switch list file for reading hostFile = open(hostFile, "r") #read each host and perform actions, sequentially for host in hostFile: #remove newlines from host host = host.strip(' \t\n\r') print "\tConnecting to " + host + "..." #connect to host via ssh try: ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect(host,username=user ,password=password) chan = ssh.invoke_shell() except: print "\n\tCould not establish session with " + host + "\n" break #if continue banner on switch, wait for it, then send newline (enter) if continueBannerSwitchListExist == "yes": # any character send trough channel to bypass the banner chan.send('a') #create string with config download command download = "copy running-config tftp %s %s.txt \n" % (tftp, host) chan.send(download) #wait to download time.sleep(3) #print status message print "\n\tDownloading running-config from " + host + "..." print "\tDone\n" #disconnect from switch ssh.close() hostFile.close()
The text was updated successfully, but these errors were encountered:
That's awesome! Thanks for your help. I'll review and merge asap. On Feb 7, 2014 6:50 AM, "cemaktas" notifications@github.com wrote:
I have use following code for ssh connection to HP Procurve switch import paramiko def readAndConnect(user, password, tftpRoot, tftp, hostFile, continueBannerSwitchListExist="no"): #open switch list file for reading hostFile = open(hostFile, "r") #read each host and perform actions, sequentially for host in hostFile: #remove newlines from host host = host.strip(' \t\n\r') print "\tConnecting to " + host + "..." #connect to host via ssh try: ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect(host,username=user ,password=password) chan = ssh.invoke_shell() except: print "\n\tCould not establish session with " + host + "\n" break #if continue banner on switch, wait for it, then send newline (enter) if continueBannerSwitchListExist == "yes": # any character send trough channel to bypass the banner chan.send('a') #create string with config download command download = "copy running-config tftp %s %s.txt \n" % (tftp, host) chan.send(download) #wait to download time.sleep(3) #print status message print "\n\tDownloading running-config from " + host + "..." print "\tDone\n" #disconnect from switch ssh.close() hostFile.close() Reply to this email directly or view it on GitHubhttps://github.com//issues/2 .
#open switch list file for reading hostFile = open(hostFile, "r")
#read each host and perform actions, sequentially for host in hostFile:
#remove newlines from host host = host.strip(' \t\n\r') print "\tConnecting to " + host + "..." #connect to host via ssh try: ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect(host,username=user ,password=password) chan = ssh.invoke_shell() except: print "\n\tCould not establish session with " + host + "\n" break #if continue banner on switch, wait for it, then send newline (enter) if continueBannerSwitchListExist == "yes": # any character send trough channel to bypass the banner chan.send('a') #create string with config download command download = "copy running-config tftp %s %s.txt \n" % (tftp, host) chan.send(download) #wait to download time.sleep(3) #print status message print "\n\tDownloading running-config from " + host + "..." print "\tDone\n" #disconnect from switch ssh.close()
hostFile.close()
Reply to this email directly or view it on GitHubhttps://github.com//issues/2 .
Sorry, something went wrong.
No branches or pull requests
I have use following code for ssh connection to HP Procurve switch
import paramiko
def readAndConnect(user, password, tftpRoot, tftp, hostFile, continueBannerSwitchListExist="no"):
The text was updated successfully, but these errors were encountered: