parameters: (self, path, passphrase=None, settings=None)
docstring: Generates a public key from the given private key at *path*.  If a
      *passphrase* is provided, it will be used to generate the public key (if
      necessary).
docstring_summary: Generates a public key from the given private key at *path*.  If a
      *passphrase* is provided, it will be used to generate the public key (if
      necessary).
docstring_tokens: Generates a public key from the given private key at * path * . If a * passphrase * is provided it will be used to generate the public key ( if necessary ) .
function: def openssh_generate_public_key(self, path, passphrase=None, settings=None):
      """
      Generates a public key from the given private key at *path*.  If a
      *passphrase* is provided, it will be used to generate the public key (if
      necessary).
      """
      self.ssh_log.debug('openssh_generate_public_key()')
      ssh_keygen_path = which('ssh-keygen')
      pubkey_path = "%s.pub" % path
      command = (
          "%s "       # Path to ssh-keygen
          "-f '%s' "  # Key path
          "-y "       # Output public key to stdout
          "2>&1 "     # Redirect stderr to stdout so we can catch failures
          "> '%s'"    # Redirect stdout to the public key path
          % (ssh_keygen_path, path, pubkey_path)
      )
      import termio
      m = termio.Multiplex(command)
      def request_passphrase(*args, **kwargs):
          "Called if this key requires a passphrase.  Ask the client to provide"
          message = {'terminal:sshjs_ask_passphrase': settings}
          self.write_message(message)
      def bad_passphrase(m_instance, match):
          "Called if the user entered a bad passphrase"
          settings['bad'] = True
          request_passphrase()
      if passphrase:
          m.expect('^Enter passphrase',
              "%s\n" % passphrase, optional=True, preprocess=False, timeout=5)
          m.expect('^load failed',
              bad_passphrase, optional=True, preprocess=False, timeout=5)
      elif settings:
          m.expect('^Enter passphrase',
              request_passphrase, optional=True, preprocess=False, timeout=5)
      def atexit(child, exitstatus):
          "Raises an SSHKeygenException if the *exitstatus* isn't 0"
          if exitstatus != 0:
              print(m.dump)
              raise SSHKeygenException(_(
                  "Error generating public key from private key at %s" % path))
      m.spawn(exitfunc=atexit)
function_tokens: def openssh_generate_public_key ( self , path , passphrase = None , settings = None ) : self . ssh_log . debug ( 'openssh_generate_public_key()' ) ssh_keygen_path = which ( 'ssh-keygen' ) pubkey_path = "%s.pub" % path command = ( "%s " # Path to ssh-keygen "-f '%s' " # Key path "-y " # Output public key to stdout "2>&1 " # Redirect stderr to stdout so we can catch failures "> '%s'" # Redirect stdout to the public key path % ( ssh_keygen_path , path , pubkey_path ) ) import termio m = termio . Multiplex ( command ) def request_passphrase ( * args , * * kwargs ) : "Called if this key requires a passphrase.  Ask the client to provide" message = { 'terminal:sshjs_ask_passphrase' : settings } self . write_message ( message ) def bad_passphrase ( m_instance , match ) : "Called if the user entered a bad passphrase" settings [ 'bad' ] = True request_passphrase ( ) if passphrase : m . expect ( '^Enter passphrase' , "%s\n" % passphrase , optional = True , preprocess = False , timeout = 5 ) m . expect ( '^load failed' , bad_passphrase , optional = True , preprocess = False , timeout = 5 ) elif settings : m . expect ( '^Enter passphrase' , request_passphrase , optional = True , preprocess = False , timeout = 5 ) def atexit ( child , exitstatus ) : "Raises an SSHKeygenException if the *exitstatus* isn't 0" if exitstatus != 0 : print ( m . dump ) raise SSHKeygenException ( _ ( "Error generating public key from private key at %s" % path ) ) m . spawn ( exitfunc = atexit )