code: def authenticate(self, driver):
          
          #              0                     1                    2                  3
          events = [driver.press_return_re, driver.password_re, self.device.prompt_re, pexpect.TIMEOUT]
  
          transitions = [
              (driver.press_return_re, [0, 1], 1, partial(a_send, "\r\n"), 10),
              (driver.password_re, [0], 1, partial(a_send_password, self._acquire_password()),
               _C['first_prompt_timeout']),
              (driver.password_re, [1], -1, a_authentication_error, 0),
              (self.device.prompt_re, [0, 1], -1, None, 0),
              (pexpect.TIMEOUT, [1], -1,
               ConnectionError("Error getting device prompt") if self.device.is_target else partial(a_send, "\r\n"), 0)
          ]
  
          self.log("EXPECTED_PROMPT={}".format(pattern_to_str(self.device.prompt_re)))
          fsm = FSM("SSH-AUTH", self.device, events, transitions, init_pattern=self.last_pattern, timeout=30)
          return fsm.run()
docs: Authenticate using the SSH protocol specific FSM.