Advertisement
Guest User

Untitled

a guest
Mar 7th, 2017
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.70 KB | None | 0 0
  1. import paramiko
  2. import logging
  3.  
  4. # Set Loglevel to debug and write log to file
  5. logging.getLogger("paramiko").setLevel(logging.DEBUG)
  6. paramiko.util.log_to_file('filename.log')
  7.  
  8.  
  9. # Create SSH Client
  10. ssh = paramiko.SSHClient()
  11. ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  12.  
  13. try:
  14.     # Connect to my virtual server.
  15.     # SSH settings were changed like in this issus track #65989
  16.     ssh.connect(hostname='172.30.10.188', username='omp', password='', timeout=30, port=22)
  17.    
  18.     # Should the program at this point be already connected to the unix socket?
  19.     # If yes, then i could send an omp protocol command
  20.     stdin, stdout,stderr_ = ssh.exec_command('<get_version/>')
  21.  
  22.     # readlines is waiting maybe.
  23.     result = stdout.readlines()
  24.     print(result)
  25.  
  26. except(paramiko.ssh_exception.SSHException, socket.error) as err:
  27.     print(err)
  28.  
  29. ssh.close()
  30.  
  31.  
  32.  
  33. # Package generated configuration file
  34. # See the sshd_config(5) manpage for details
  35.  
  36. # What ports, IPs and protocols we listen for
  37. Port 22
  38. # Use these options to restrict which interfaces/protocols sshd will bind to
  39. #ListenAddress ::
  40. #ListenAddress 0.0.0.0
  41. Protocol 2
  42. # HostKeys for protocol version 2
  43. HostKey /etc/ssh/ssh_host_rsa_key
  44. HostKey /etc/ssh/ssh_host_dsa_key
  45. HostKey /etc/ssh/ssh_host_ecdsa_key
  46. HostKey /etc/ssh/ssh_host_ed25519_key
  47. #Privilege Separation is turned on for security
  48. UsePrivilegeSeparation yes
  49.  
  50. # Lifetime and size of ephemeral version 1 server key
  51. KeyRegenerationInterval 3600
  52. ServerKeyBits 1024
  53.  
  54. # Logging
  55. SyslogFacility AUTH
  56. LogLevel INFO
  57.  
  58. # Authentication:
  59. LoginGraceTime 120
  60. PermitRootLogin without-password
  61. #PermitRootLogin yes
  62. StrictModes yes
  63.  
  64. RSAAuthentication yes
  65. PubkeyAuthentication yes
  66. #AuthorizedKeysFile     %h/.ssh/authorized_keys
  67.  
  68. # Don't read the user's ~/.rhosts and ~/.shosts files
  69. IgnoreRhosts yes
  70. # For this to work you will also need host keys in /etc/ssh_known_hosts
  71. RhostsRSAAuthentication no
  72. # similar for protocol version 2
  73. HostbasedAuthentication no
  74. # Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
  75. #IgnoreUserKnownHosts yes
  76.  
  77. # To enable empty passwords, change to yes (NOT RECOMMENDED)
  78. PermitEmptyPasswords no
  79.  
  80. # Change to yes to enable challenge-response passwords (beware issues with
  81. # some PAM modules and threads)
  82. ChallengeResponseAuthentication no
  83.  
  84. # Change to no to disable tunnelled clear text passwords
  85. #PasswordAuthentication yes
  86.  
  87. # Kerberos options
  88. #KerberosAuthentication no
  89. #KerberosGetAFSToken no
  90. #KerberosOrLocalPasswd yes
  91. #KerberosTicketCleanup yes
  92.  
  93. # GSSAPI options
  94. #GSSAPIAuthentication no
  95. #GSSAPICleanupCredentials yes
  96.  
  97. X11Forwarding yes
  98. #X11UseLocalhost no
  99. X11DisplayOffset 10
  100. PrintMotd no
  101. PrintLastLog yes
  102. TCPKeepAlive yes
  103. #UseLogin no
  104.  
  105. #MaxStartups 10:30:60
  106. #Banner /etc/issue.net
  107.  
  108. # Allow client to pass locale environment variables
  109. AcceptEnv LANG LC_*
  110. AcceptEnv EMAIL
  111.  
  112. Subsystem sftp /usr/lib/openssh/sftp-server
  113.  
  114. # Set this to 'yes' to enable PAM authentication, account processing,
  115. # and session processing. If this is enabled, PAM authentication will
  116. # be allowed through the ChallengeResponseAuthentication and
  117. # PasswordAuthentication.  Depending on your PAM configuration,
  118. # PAM authentication via ChallengeResponseAuthentication may bypass
  119. # the setting of "PermitRootLogin without-password".
  120. # If you just want the PAM account and session checks to run without
  121. # PAM authentication, then enable this but set PasswordAuthentication
  122. # and ChallengeResponseAuthentication to 'no'.
  123. UsePAM yes
  124. #StreamLocalBindUnlink yes
  125. #GatewayPorts yes
  126. Match User omp
  127.     PermitEmptyPasswords yes
  128.  
  129. Match User omp
  130.     ForceCommand /usr/bin/socat UNIX-CONNECT:/usr/local/var/run/openvasmd.sock -
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement