Funktionierender Prototyp des Serious Games zur Vermittlung von Wissen zu Software-Engineering-Arbeitsmodellen.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cred_sshkeys.py 1.4KB

1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # -*- test-case-name: twisted.test.test_strcred -*-
  2. #
  3. # Copyright (c) Twisted Matrix Laboratories.
  4. # See LICENSE for details.
  5. """
  6. Cred plugin for ssh key login.
  7. """
  8. from zope.interface import implementer
  9. from twisted import plugin
  10. from twisted.cred.strcred import ICheckerFactory
  11. sshKeyCheckerFactoryHelp = """
  12. This allows SSH public key authentication, based on public keys listed in
  13. authorized_keys and authorized_keys2 files in user .ssh/ directories.
  14. """
  15. try:
  16. from twisted.conch.checkers import SSHPublicKeyChecker, UNIXAuthorizedKeysFiles
  17. @implementer(ICheckerFactory, plugin.IPlugin)
  18. class SSHKeyCheckerFactory:
  19. """
  20. Generates checkers that will authenticate a SSH public key
  21. """
  22. authType = "sshkey"
  23. authHelp = sshKeyCheckerFactoryHelp
  24. argStringFormat = "No argstring required."
  25. credentialInterfaces = SSHPublicKeyChecker.credentialInterfaces
  26. def generateChecker(self, argstring=""):
  27. """
  28. This checker factory ignores the argument string. Everything
  29. needed to authenticate users is pulled out of the public keys
  30. listed in user .ssh/ directories.
  31. """
  32. return SSHPublicKeyChecker(UNIXAuthorizedKeysFiles())
  33. theSSHKeyCheckerFactory = SSHKeyCheckerFactory()
  34. except ImportError:
  35. # if checkers can't be imported, then there should be no SSH cred plugin
  36. pass