forked from shaba/openuds
fingerprints is a comma separated string
This commit is contained in:
parent
1983a218cb
commit
71d6e389ea
@ -23,7 +23,7 @@ class CheckfingerPrints(paramiko.MissingHostKeyPolicy):
|
|||||||
def missing_host_key(self, client, hostname, key):
|
def missing_host_key(self, client, hostname, key):
|
||||||
if self.fingerPrints:
|
if self.fingerPrints:
|
||||||
remotefingerPrints = hexlify(key.get_fingerprint()).decode().lower()
|
remotefingerPrints = hexlify(key.get_fingerprint()).decode().lower()
|
||||||
if remotefingerPrints not in self.fingerPrints:
|
if remotefingerPrints not in self.fingerPrints.split(','):
|
||||||
logger.error("Server {!r} has invalid fingerPrints. ({} vs {})".format(hostname, remotefingerPrints, self.fingerPrints))
|
logger.error("Server {!r} has invalid fingerPrints. ({} vs {})".format(hostname, remotefingerPrints, self.fingerPrints))
|
||||||
raise paramiko.SSHException(
|
raise paramiko.SSHException(
|
||||||
"Server {!r} has invalid fingerPrints".format(hostname)
|
"Server {!r} has invalid fingerPrints".format(hostname)
|
||||||
@ -136,6 +136,7 @@ class ForwardThread(threading.Thread):
|
|||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
if self.client is None:
|
if self.client is None:
|
||||||
|
try:
|
||||||
self.client = paramiko.SSHClient()
|
self.client = paramiko.SSHClient()
|
||||||
self.client.useCount = 1 # Custom added variable, to keep track on when to close tunnel
|
self.client.useCount = 1 # Custom added variable, to keep track on when to close tunnel
|
||||||
self.client.load_system_host_keys()
|
self.client.load_system_host_keys()
|
||||||
@ -143,7 +144,6 @@ class ForwardThread(threading.Thread):
|
|||||||
|
|
||||||
logger.debug('Connecting to ssh host %s:%d ...', self.server, self.port)
|
logger.debug('Connecting to ssh host %s:%d ...', self.server, self.port)
|
||||||
|
|
||||||
try:
|
|
||||||
self.client.connect(self.server, self.port, username=self.username, password=self.password, timeout=5)
|
self.client.connect(self.server, self.port, username=self.username, password=self.password, timeout=5)
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.exception('Exception connecting: ')
|
logger.exception('Exception connecting: ')
|
||||||
|
@ -28,7 +28,8 @@ class CheckfingerPrints(paramiko.MissingHostKeyPolicy):
|
|||||||
def missing_host_key(self, client, hostname, key):
|
def missing_host_key(self, client, hostname, key):
|
||||||
if self.fingerPrints:
|
if self.fingerPrints:
|
||||||
remotefingerPrints = hexlify(key.get_fingerprint()).decode().lower()
|
remotefingerPrints = hexlify(key.get_fingerprint()).decode().lower()
|
||||||
if remotefingerPrints not in self.fingerPrints:
|
logger.debug('Checking keys {} against {}'.format(remotefingerPrints, self.fingerPrints))
|
||||||
|
if remotefingerPrints not in self.fingerPrints.split(','):
|
||||||
logger.error("Server {!r} has invalid fingerPrints. ({} vs {})".format(hostname, remotefingerPrints, self.fingerPrints))
|
logger.error("Server {!r} has invalid fingerPrints. ({} vs {})".format(hostname, remotefingerPrints, self.fingerPrints))
|
||||||
raise paramiko.SSHException(
|
raise paramiko.SSHException(
|
||||||
"Server {!r} has invalid fingerPrints".format(hostname)
|
"Server {!r} has invalid fingerPrints".format(hostname)
|
||||||
|
Loading…
Reference in New Issue
Block a user