diff options
-rw-r--r-- | paramiko/auth_handler.py | 5 | ||||
-rw-r--r-- | paramiko/transport.py | 12 |
2 files changed, 17 insertions, 0 deletions
diff --git a/paramiko/auth_handler.py b/paramiko/auth_handler.py index acb7c8b8..da551afa 100644 --- a/paramiko/auth_handler.py +++ b/paramiko/auth_handler.py @@ -45,6 +45,7 @@ class AuthHandler (object): self.authenticated = False self.auth_event = None self.auth_method = '' + self.banner = None self.password = None self.private_key = None self.interactive_handler = None @@ -62,6 +63,9 @@ class AuthHandler (object): else: return self.username + def get_banner(self): + return self.banner + def auth_none(self, username, event): self.transport.lock.acquire() try: @@ -375,6 +379,7 @@ class AuthHandler (object): def _parse_userauth_banner(self, m): banner = m.get_string() + self.banner = banner lang = m.get_string() self.transport._log(INFO, 'Auth banner: ' + banner) # who cares. diff --git a/paramiko/transport.py b/paramiko/transport.py index 6c42cc27..951e36a4 100644 --- a/paramiko/transport.py +++ b/paramiko/transport.py @@ -1092,6 +1092,18 @@ class Transport (threading.Thread): return None return self.auth_handler.get_username() + def get_banner(self): + """ + Return the banner supplied by the server upon connect. If no banner is supplied, + this method returns C{None}. + + @return: server supplied banner, or C{None}. + @rtype: string + """ + if not self.active or (self.auth_handler is None): + return None + return self.auth_handler.get_banner() + def auth_none(self, username): """ Try to authenticate to the server using no authentication at all. |