diff options
-rw-r--r-- | README | 2 | ||||
-rw-r--r-- | paramiko/auth_handler.py | 2 | ||||
-rw-r--r-- | paramiko/transport.py | 12 | ||||
-rw-r--r-- | sites/www/changelog.rst | 2 |
4 files changed, 17 insertions, 1 deletions
@@ -5,7 +5,7 @@ paramiko :Paramiko: Python SSH module :Copyright: Copyright (c) 2003-2009 Robey Pointer <robeypointer@gmail.com> -:Copyright: Copyright (c) 2013 Jeff Forcier <jeff@bitprophet.org> +:Copyright: Copyright (c) 2014 Jeff Forcier <jeff@bitprophet.org> :License: LGPL :Homepage: https://github.com/paramiko/paramiko/ :API docs: http://docs.paramiko.org diff --git a/paramiko/auth_handler.py b/paramiko/auth_handler.py index 0c9efa14..a6f52550 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 @@ -375,6 +376,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 ad245a69..9f5c7098 100644 --- a/paramiko/transport.py +++ b/paramiko/transport.py @@ -951,6 +951,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.banner + def auth_none(self, username): """ Try to authenticate to the server using no authentication at all. diff --git a/sites/www/changelog.rst b/sites/www/changelog.rst index fbb44da4..3827bfe4 100644 --- a/sites/www/changelog.rst +++ b/sites/www/changelog.rst @@ -12,6 +12,8 @@ Changelog * :release:`1.12.2 <2014-02-14>` * :release:`1.11.4 <2014-02-14>` * :release:`1.10.6 <2014-02-14>` +* :feature:`58` Allow client code to access the stored SSH server banner via + ``Transport.get_banner()``. Thanks to ``@Jhoanor`` for the patch. * :bug:`252` (`Fabric #1020 <https://github.com/fabric/fabric/issues/1020>`_) Enhanced the implementation of ``ProxyCommand`` to avoid a deadlock/hang condition that frequently occurs at ``Transport`` shutdown time. Thanks to |