Guest User

Untitled

a guest
Oct 27th, 2017
649
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. ['200', '530', '540']
  2.  
  3. ssh_conn.send('show running-config crypto map | i 200n')
  4. ssh_conn.send('show running-config crypto map | i 530n')
  5. ssh_conn.send('show running-config crypto map | i 540n')
  6.  
  7. #!/usr/bin/env python
  8.  
  9. import paramiko
  10. import time
  11. import re
  12.  
  13. # Variables
  14. host = xxxx = 'xxxxx'
  15.  
  16. # Create instance of SSHClient object
  17. ssh = paramiko.SSHClient()
  18.  
  19. # Automatically add untrusted hosts
  20. ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  21. # Automatically add untrusted hosts
  22. ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  23.  
  24. # initiate SSH connection
  25. ssh.connect('xxxxx', port=22, username='xxxx', password='xxxxx', look_for_keys=False, allow_agent=False)
  26. print "SSH COnnection established with %s" % host
  27.  
  28. # Use invoke_shell to establish an 'interactive session'
  29. ssh_conn = ssh.invoke_shell()
  30. print "Interactive SSH session established"
  31.  
  32. print "Give the name of the 3PPartnern"
  33. partner = raw_input('>')
  34.  
  35. # Commands prompted
  36. ssh_conn.send('n')
  37. ssh_conn.send('enablen')
  38. time.sleep(.5)
  39. ssh_conn.send('xxxxxn')
  40. time.sleep(.5)
  41. ssh_conn.send("terminal pager 0n")
  42. time.sleep(.5)
  43. ssh_conn.send('show running-config crypto map | i ' + str(partner) + 'n')
  44. time.sleep(1)
  45.  
  46. output = ssh_conn.recv(65535)
  47. print output
  48.  
  49. crypto_list = re.findall("OUTSIDEMAP (d+) match",output)
  50. print crypto_list
  51.  
  52. python IPSEC_config_attributes.py
  53. SSH COnnection established with XXXX
  54. Interactive SSH session established
  55. Give the name of the 3PPartner
  56.  
  57. >XXXX
  58. Type help or '?' for a list of available commands.
  59. XXXX/pri/act>
  60. XXXX/pri/act> enable
  61. Password: ************
  62. XXXX/pri/act# terminal pager 0
  63. XXXX/pri/act# show running-config crypto map | i XXX
  64. crypto map OUTSIDEMAP 200 match address XXXX
  65. crypto map OUTSIDEMAP 530 match address XXXX
  66. crypto map OUTSIDEMAP 540 match address XXXX
  67. XXXX/pri/act#
  68. ['200', '530', '540']
  69. 200
  70. 530
  71. 540
  72. Logged out of device XXXXXXXX
Add Comment
Please, Sign In to add comment