Added test for bad authentication type

This commit is contained in:
Sheng
2018-08-26 21:53:28 +08:00
parent 105c1f62ee
commit e1fbc417fd
2 changed files with 25 additions and 7 deletions
+3 -1
View File
@@ -72,11 +72,13 @@ class Server(paramiko.ServerInterface):
def check_auth_publickey(self, username, key):
print('Auth attempt with username: {!r} & key: {!r}'.format(username, u(hexlify(key.get_fingerprint())))) # noqa
if (username == 'robey') and (key == self.good_pub_key):
if (username in ['robey', 'keyonly']) and (key == self.good_pub_key):
return paramiko.AUTH_SUCCESSFUL
return paramiko.AUTH_FAILED
def get_allowed_auths(self, username):
if username == 'keyonly':
return 'publickey'
return 'password,publickey'
def check_channel_exec_request(self, channel, command):