class_docstr: This class extends pexpect.spawn to specialize setting up SSH
  connections. This adds methods for login, logout, and expecting the shell
  prompt. It does various tricky things to handle many situations in the SSH
  login process. For example, if the session is your first login, then pxssh
  automatically accepts the remote certificate; or if you have public key
  authentication setup then pxssh won't wait for the password prompt.
  
  pxssh uses the shell prompt to synchronize output from the remote host. In
  order to make this more robust it sets the shell prompt to something more
  unique than just $ or #. This should work on most Borne/Bash or Csh style
  shells.
  
  Example that runs a few commands on a remote server and prints the result::
  
      from pexpect import pxssh
      import getpass
      try:
          s = pxssh.pxssh()
          hostname = raw_input('hostname: ')
          username = raw_input('username: ')
          password = getpass.getpass('password: ')
          s.login(hostname, username, password)
          s.sendline('uptime')   # run a command
          s.prompt()             # match the prompt
          print(s.before)        # print everything before the prompt.
          s.sendline('ls -l')
          s.prompt()
          print(s.before)
          s.sendline('df')
          s.prompt()
          print(s.before)
          s.logout()
      except pxssh.ExceptionPxssh as e:
          print("pxssh failed on login.")
          print(e)
  
  Example showing how to specify SSH options::
  
      from pexpect import pxssh
      s = pxssh.pxssh(options={
                          "StrictHostKeyChecking": "no",
                          "UserKnownHostsFile": "/dev/null"})
      ...
  
  Note that if you have ssh-agent running while doing development with pxssh
  then this can lead to a lot of confusion. Many X display managers (xdm,
  gdm, kdm, etc.) will automatically start a GUI agent. You may see a GUI
  dialog box popup asking for a password during development. You should turn
  off any key agents during testing. The 'force_password' attribute will turn
  off public key authentication. This will only work if the remote SSH server
  is configured to allow password logins. Example of using 'force_password'
  attribute::
  
          s = pxssh.pxssh()
          s.force_password = True
          hostname = raw_input('hostname: ')
          username = raw_input('username: ')
          password = getpass.getpass('password: ')
          s.login (hostname, username, password)
  
  `debug_command_string` is only for the test suite to confirm that the string
  generated for SSH is correct, using this will not allow you to do
  anything other than get a string back from `pxssh.pxssh.login()`.
class_docstr_tok: ["This","class","extends","pexpect.spawn","to","specialize","setting","up","SSH","connections",".","This","adds","methods","for","login",",","logout",",","and","expecting","the","shell","prompt",".","It","does","various","tricky","things","to","handle","many","situations","in","the","SSH","login","process",".","For","example",",","if","the","session","is","your","first","login",",","then","pxssh","automatically","accepts","the","remote","certificate",";","or","if","you","have","public","key","authentication","setup","then","pxssh","wo","n't","wait","for","the","password","prompt",".","pxssh","uses","the","shell","prompt","to","synchronize","output","from","the","remote","host",".","In","order","to","make","this","more","robust","it","sets","the","shell","prompt","to","something","more","unique","than","just","$","or","#",".","This","should","work","on","most","Borne\/Bash","or","Csh","style","shells",".","Example","that","runs","a","few","commands","on","a","remote","server","and","prints","the","result",":",":","from","pexpect","import","pxssh","import","getpass","try",":","s","=","pxssh.pxssh","(",")","hostname","=","raw_input","(","'hostname",":","'",")","username","=","raw_input","(","'username",":","'",")","password","=","getpass.getpass","(","'password",":","'",")","s.login","(","hostname",",","username",",","password",")","s.sendline","(","'uptime","'",")","#","run","a","command","s.prompt","(",")","#","match","the","prompt","print","(","s.before",")","#","print","everything","before","the","prompt",".","s.sendline","(","'ls","-l","'",")","s.prompt","(",")","print","(","s.before",")","s.sendline","(","'df","'",")","s.prompt","(",")","print","(","s.before",")","s.logout","(",")","except","pxssh.ExceptionPxssh","as","e",":","print","(","``","pxssh","failed","on","login",".","''",")","print","(","e",")","Example","showing","how","to","specify","SSH","options",":",":","from","pexpect","import","pxssh","s","=","pxssh.pxssh","(","options=","{","``","StrictHostKeyChecking","''",":","``","no","''",",","``","UserKnownHostsFile","''",":","``","\/dev\/null","''","}",")","...","Note","that","if","you","have","ssh-agent","running","while","doing","development","with","pxssh","then","this","can","lead","to","a","lot","of","confusion",".","Many","X","display","managers","(","xdm",",","gdm",",","kdm",",","etc",".",")","will","automatically","start","a","GUI","agent",".","You","may","see","a","GUI","dialog","box","popup","asking","for","a","password","during","development",".","You","should","turn","off","any","key","agents","during","testing",".","The","'force_password","'","attribute","will","turn","off","public","key","authentication",".","This","will","only","work","if","the","remote","SSH","server","is","configured","to","allow","password","logins",".","Example","of","using","'force_password'","attribute",":",":","s","=","pxssh.pxssh","(",")","s.force_password","=","True","hostname","=","raw_input","(","'hostname",":","'",")","username","=","raw_input","(","'username",":","'",")","password","=","getpass.getpass","(","'password",":","'",")","s.login","(","hostname",",","username",",","password",")","`","debug_command_string","`","is","only","for","the","test","suite","to","confirm","that","the","string","generated","for","SSH","is","correct",",","using","this","will","not","allow","you","to","do","anything","other","than","get","a","string","back","from","`","pxssh.pxssh.login","(",")","`","."]
code: def __init__(
      self,
      timeout=30,
      maxread=2000,
      searchwindowsize=None,
      logfile=None,
      cwd=None,
      env=None,
      ignore_sighup=True,
      echo=True,
      options={},
      encoding=None,
      codec_errors="strict",
      debug_command_string=False,
      use_poll=False,
  ):
      spawn.__init__(
          self,
          None,
          timeout=timeout,
          maxread=maxread,
          searchwindowsize=searchwindowsize,
          logfile=logfile,
          cwd=cwd,
          env=env,
          ignore_sighup=ignore_sighup,
          echo=echo,
          encoding=encoding,
          codec_errors=codec_errors,
          use_poll=use_poll,
      )
  
      self.name = "<pxssh>"
  
      # SUBTLE HACK ALERT! Note that the command that SETS the prompt uses a
      # slightly different string than the regular expression to match it. This
      # is because when you set the prompt the command will echo back, but we
      # don't want to match the echoed command. So if we make the set command
      # slightly different than the regex we eliminate the problem. To make the
      # set command different we add a backslash in front of $. The $ doesn't
      # need to be escaped, but it doesn't hurt and serves to make the set
      # prompt command different than the regex.
  
      # used to match the command-line prompt
      self.UNIQUE_PROMPT = r"\[PEXPECT\][\$\#] "
      self.PROMPT = self.UNIQUE_PROMPT
  
      # used to set shell command-line prompt to UNIQUE_PROMPT.
      self.PROMPT_SET_SH = r"PS1='[PEXPECT]\$ '"
      self.PROMPT_SET_CSH = r"set prompt='[PEXPECT]\$ '"
      self.PROMPT_SET_ZSH = "prompt restore;\nPS1='[PEXPECT]%(!.#.$) '"
      self.SSH_OPTS = " -o 'PubkeyAuthentication=no'"
      # Disabling host key checking, makes you vulnerable to MITM attacks.
      #                + " -o 'StrictHostKeyChecking=no'"
      #                + " -o 'UserKnownHostsFile /dev/null' ")
      # Disabling X11 forwarding gets rid of the annoying SSH_ASKPASS from
      # displaying a GUI password dialog. I have not figured out how to
      # disable only SSH_ASKPASS without also disabling X11 forwarding.
      # Unsetting SSH_ASKPASS on the remote side doesn't disable it! Annoying!
      # self.SSH_OPTS = "-x -o 'PubkeyAuthentication=no'"
      self.force_password = False
  
      self.debug_command_string = debug_command_string
  
      # User defined SSH options, eg,
      # ssh.otions = dict(StrictHostKeyChecking="no",UserKnownHostsFile="/dev/null")
      self.options = options
  
file_path: catboost/contrib/python/pexpect/py2/pexpect/pxssh.py
imports: from pexpect import ExceptionPexpect, TIMEOUT, EOF, spawn
  import time
  import os
  import sys
  import re
label_desc: Use image node_id 1 to create a new pxssh object from inherited base classes: spawn with example: obj = pxssh(timeout, maxread, searchwindowsize, logfile, cwd, env, ignore_sighup, echo, options, encoding, codec_errors, debug_command_string, use_poll)