1 # -*- test-case-name: twisted.test.test_strcred -*-
3 # Copyright (c) Twisted Matrix Laboratories.
4 # See LICENSE for details.
7 Cred plugin for ssh key login
10 from zope.interface import implements
12 from twisted import plugin
13 from twisted.cred.strcred import ICheckerFactory
14 from twisted.cred.credentials import ISSHPrivateKey
17 sshKeyCheckerFactoryHelp = """
18 This allows SSH public key authentication, based on public keys listed in
19 authorized_keys and authorized_keys2 files in user .ssh/ directories.
24 from twisted.conch.checkers import SSHPublicKeyDatabase
26 class SSHKeyCheckerFactory(object):
28 Generates checkers that will authenticate a SSH public key
30 implements(ICheckerFactory, plugin.IPlugin)
32 authHelp = sshKeyCheckerFactoryHelp
33 argStringFormat = 'No argstring required.'
34 credentialInterfaces = SSHPublicKeyDatabase.credentialInterfaces
37 def generateChecker(self, argstring=''):
39 This checker factory ignores the argument string. Everything
40 needed to authenticate users is pulled out of the public keys
41 listed in user .ssh/ directories.
43 return SSHPublicKeyDatabase()
47 theSSHKeyCheckerFactory = SSHKeyCheckerFactory()
50 # if checkers can't be imported, then there should be no SSH cred plugin