本文整理汇总了Python中paramiko.HostKeys方法的典型用法代码示例。如果您正苦于以下问题:Python paramiko.HostKeys方法的具体用法?Python paramiko.HostKeys怎么用?Python paramiko.HostKeys使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类paramiko
的用法示例。
在下文中一共展示了paramiko.HostKeys方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_4_dict_set
# 需要导入模块: import paramiko [as 别名]
# 或者: from paramiko import HostKeys [as 别名]
def test_4_dict_set(self):
hostdict = paramiko.HostKeys('hostfile.temp')
key = paramiko.RSAKey(data=decodebytes(keyblob))
key_dss = paramiko.DSSKey(data=decodebytes(keyblob_dss))
hostdict['secure.example.com'] = {
'ssh-rsa': key,
'ssh-dss': key_dss
}
hostdict['fake.example.com'] = {}
hostdict['fake.example.com']['ssh-rsa'] = key
self.assertEqual(3, len(hostdict))
self.assertEqual(2, len(list(hostdict.values())[0]))
self.assertEqual(1, len(list(hostdict.values())[1]))
self.assertEqual(1, len(list(hostdict.values())[2]))
fp = hexlify(hostdict['secure.example.com']['ssh-rsa'].get_fingerprint()).upper()
self.assertEqual(b'7EC91BB336CB6D810B124B1353C32396', fp)
fp = hexlify(hostdict['secure.example.com']['ssh-dss'].get_fingerprint()).upper()
self.assertEqual(b'4478F0B9A23CC5182009FF755BC1D26C', fp)
示例2: __init__
# 需要导入模块: import paramiko [as 别名]
# 或者: from paramiko import HostKeys [as 别名]
def __init__(self, capabilities):
Session.__init__(self, capabilities)
self._host_keys = paramiko.HostKeys()
self._transport = None
self._connected = False
self._channel = None
self._buffer = StringIO() # for incoming data
# parsing-related, see _parse()
self._parsing_state = 0
self._parsing_pos = 0
示例3: __init__
# 需要导入模块: import paramiko [as 别名]
# 或者: from paramiko import HostKeys [as 别名]
def __init__(self):
'''
initialize
'''
self.__t = None
self.__chan = None
self.__sock = None
self.__temp_buf = ""
Thread.__init__(self)
self.setDaemon(True)
self.__host_keys = paramiko.HostKeys()
self.__wait_resp = Event()
self.__wait_resp.clear()
self.__wait_rept = Event()
self.__wait_rept.clear()
self.__response_buffer = ""
self.__hello_buffer = ""
self.__session_id = None
self.__isCOMPLD = False
self.__error_message = ""
self.__isOpen = False
self.__send_data = ""
self.__protocol_ver = "1.0"
self.__notification_list = []
self.__wait_string = ("", {})
self.__host_name = ""
self.__exp_protocol_version = ""
self.__notification_list_print = []
示例4: test_1_load
# 需要导入模块: import paramiko [as 别名]
# 或者: from paramiko import HostKeys [as 别名]
def test_1_load(self):
hostdict = paramiko.HostKeys('hostfile.temp')
self.assertEqual(2, len(hostdict))
self.assertEqual(1, len(list(hostdict.values())[0]))
self.assertEqual(1, len(list(hostdict.values())[1]))
fp = hexlify(hostdict['secure.example.com']['ssh-rsa'].get_fingerprint()).upper()
self.assertEqual(b'E6684DB30E109B67B70FF1DC5C7F1363', fp)
示例5: test_2_add
# 需要导入模块: import paramiko [as 别名]
# 或者: from paramiko import HostKeys [as 别名]
def test_2_add(self):
hostdict = paramiko.HostKeys('hostfile.temp')
hh = '|1|BMsIC6cUIP2zBuXR3t2LRcJYjzM=|hpkJMysjTk/+zzUUzxQEa2ieq6c='
key = paramiko.RSAKey(data=decodebytes(keyblob))
hostdict.add(hh, 'ssh-rsa', key)
self.assertEqual(3, len(list(hostdict)))
x = hostdict['foo.example.com']
fp = hexlify(x['ssh-rsa'].get_fingerprint()).upper()
self.assertEqual(b'7EC91BB336CB6D810B124B1353C32396', fp)
self.assertTrue(hostdict.check('foo.example.com', key))
示例6: test_3_dict
# 需要导入模块: import paramiko [as 别名]
# 或者: from paramiko import HostKeys [as 别名]
def test_3_dict(self):
hostdict = paramiko.HostKeys('hostfile.temp')
self.assertTrue('secure.example.com' in hostdict)
self.assertTrue('not.example.com' not in hostdict)
self.assertTrue('secure.example.com' in hostdict)
self.assertTrue('not.example.com' not in hostdict)
x = hostdict.get('secure.example.com', None)
self.assertTrue(x is not None)
fp = hexlify(x['ssh-rsa'].get_fingerprint()).upper()
self.assertEqual(b'E6684DB30E109B67B70FF1DC5C7F1363', fp)
i = 0
for key in hostdict:
i += 1
self.assertEqual(2, i)
示例7: test_delitem
# 需要导入模块: import paramiko [as 别名]
# 或者: from paramiko import HostKeys [as 别名]
def test_delitem(self):
hostdict = paramiko.HostKeys('hostfile.temp')
target = 'happy.example.com'
entry = hostdict[target] # will KeyError if not present
del hostdict[target]
try:
entry = hostdict[target]
except KeyError:
pass # Good
else:
assert False, "Entry was not deleted from HostKeys on delitem!"