exscript icon indicating copy to clipboard operation
exscript copied to clipboard

Rewrite auth mechanism proposal

Open u1735067 opened this issue 5 years ago • 2 comments

  • Try auth_password first (it should be the most common for network equipments and some of them don't like auth_none as first method, requiring reconnection
  • Use correct display names
  • Remove redundant code (error handling)
  • Allow some partial auth support (might not work)
  • Banner is retrieved and tested at each auth attempt, because some equipments send it only once even is the method failed
  • Some Python3 compatibility "hack" (get_banner), there's a lot to change to be fully Python3 compatible I think (unicode_literals from __future__ everywhere, as str in Py2 is basically bytes)

u1735067 avatar Aug 22 '19 14:08 u1735067

Coverage Status

Coverage decreased (-0.07%) to 76.718% when pulling ef2ae013b182b4b74a1aefca4ef449fff2abec04 on Alex131089:rewrite-auth-mechanism into 5c7c6251a5b0c5140c738418b6bca34ed35e942d on knipknap:master.

coveralls avatar Aug 22 '19 20:08 coveralls

As a workaround I landed up extending the SSH protocol class.

` class SSH2(PSSH2):

  def _paramiko_auth(self, username, password):
      """Override Exscript's default behaviour since we only use
      one auth type (password).
      """
      method = self._paramiko_auth_password
      self._dbg(1, 'Authenticating with %s' % method.__name__)
      try:
          method(username, password)
          return
      except BadHostKeyException as e:
          msg = '%s: Bad host key: %s' % (method.__name__, str(e))
          self._dbg(1, msg)
      except AuthenticationException as e:
          msg = 'Authentication with %s failed' % method.__name__
          msg += ': ' + str(e)
          self._dbg(1, msg)
      except SSHException as e:
          msg = '%s: SSHException: %s' % (method.__name__, str(e))
          self._dbg(1, msg)
      raise LoginFailure('Login failed: ' + msg)

`

int3rlop3r avatar Apr 09 '21 13:04 int3rlop3r