当前位置: 首页>>代码示例>>Python>>正文


Python paramiko.HostKeys方法代码示例

本文整理汇总了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) 
开发者ID:hpe-storage,项目名称:python-hpedockerplugin,代码行数:21,代码来源:test_hostkeys.py

示例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 
开发者ID:OpenState-SDN,项目名称:ryu,代码行数:12,代码来源:ssh.py

示例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 = [] 
开发者ID:warriorframework,项目名称:warriorframework,代码行数:30,代码来源:netconf.py

示例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) 
开发者ID:hpe-storage,项目名称:python-hpedockerplugin,代码行数:9,代码来源:test_hostkeys.py

示例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)) 
开发者ID:hpe-storage,项目名称:python-hpedockerplugin,代码行数:12,代码来源:test_hostkeys.py

示例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) 
开发者ID:hpe-storage,项目名称:python-hpedockerplugin,代码行数:16,代码来源:test_hostkeys.py

示例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!" 
开发者ID:hpe-storage,项目名称:python-hpedockerplugin,代码行数:13,代码来源:test_hostkeys.py


注:本文中的paramiko.HostKeys方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。