• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python crypto.ssh_encrypt_text函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中nova.crypto.ssh_encrypt_text函数的典型用法代码示例。如果您正苦于以下问题:Python ssh_encrypt_text函数的具体用法?Python ssh_encrypt_text怎么用?Python ssh_encrypt_text使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ssh_encrypt_text函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _save_instance_password_if_sshkey_present

 def _save_instance_password_if_sshkey_present(self, new_pass):
     sshkey = self.instance.get("key_data")
     if sshkey and sshkey.startswith("ssh-rsa"):
         ctxt = context.get_admin_context()
         enc = crypto.ssh_encrypt_text(sshkey, new_pass)
         self.instance.system_metadata.update(password.convert_password(ctxt, base64.b64encode(enc)))
         self.instance.save()
开发者ID:markmc,项目名称:nova,代码行数:7,代码来源:agent.py


示例2: _save_instance_password_if_sshkey_present

 def _save_instance_password_if_sshkey_present(self, new_pass):
     sshkey = self.instance.get("key_data")
     if sshkey and sshkey.startswith("ssh-rsa"):
         ctxt = context.get_admin_context()
         enc = crypto.ssh_encrypt_text(sshkey, new_pass)
         sys_meta = utils.instance_sys_meta(self.instance)
         sys_meta.update(password.convert_password(ctxt, base64.b64encode(enc)))
         self.virtapi.instance_update(ctxt, self.instance["uuid"], {"system_metadata": sys_meta})
开发者ID:syotani,项目名称:nova,代码行数:8,代码来源:agent.py


示例3: _save_instance_password_if_sshkey_present

 def _save_instance_password_if_sshkey_present(self, new_pass):
     sshkey = self.instance.get('key_data')
     if sshkey:
         ctxt = context.get_admin_context()
         enc = crypto.ssh_encrypt_text(sshkey, new_pass)
         sys_meta = utils.instance_sys_meta(self.instance)
         sys_meta.update(password.convert_password(ctxt,
                                                   base64.b64encode(enc)))
         self.virtapi.instance_update(ctxt, self.instance['uuid'],
                                      {'system_metadata': sys_meta})
开发者ID:iBeacons,项目名称:nova,代码行数:10,代码来源:agent.py


示例4: set_admin_password

    def set_admin_password(self, new_pass):
        """Set the root/admin password on the VM instance.

        This is done via an agent running on the VM. Communication between nova
        and the agent is done via writing xenstore records. Since communication
        is done over the XenAPI RPC calls, we need to encrypt the password.
        We're using a simple Diffie-Hellman class instead of a more advanced
        library (such as M2Crypto) for compatibility with the agent code.
        """
        LOG.debug(_('Setting admin password'), instance=self.instance)

        dh = SimpleDH()

        # Exchange keys
        args = {'pub': str(dh.get_public())}
        resp = _call_agent(
            self.session, self.instance, self.vm_ref, 'key_init', args)

        # Successful return code from key_init is 'D0'
        if resp['returncode'] != 'D0':
            msg = _('Failed to exchange keys: %(resp)r') % locals()
            LOG.error(msg, instance=self.instance)
            raise NotImplementedError(msg)

        # Some old versions of the Windows agent have a trailing \\r\\n
        # (ie CRLF escaped) for some reason. Strip that off.
        agent_pub = int(resp['message'].replace('\\r\\n', ''))
        dh.compute_shared(agent_pub)

        # Some old versions of Linux and Windows agent expect trailing \n
        # on password to work correctly.
        enc_pass = dh.encrypt(new_pass + '\n')

        # Send the encrypted password
        args = {'enc_pass': enc_pass}
        resp = _call_agent(
            self.session, self.instance, self.vm_ref, 'password', args)

        # Successful return code from password is '0'
        if resp['returncode'] != '0':
            msg = _('Failed to update password: %(resp)r') % locals()
            LOG.error(msg, instance=self.instance)
            raise NotImplementedError(msg)

        sshkey = self.instance.get('key_data')
        if sshkey:
            ctxt = context.get_admin_context()
            enc = crypto.ssh_encrypt_text(sshkey, new_pass)
            sys_meta = utils.metadata_to_dict(self.instance['system_metadata'])
            sys_meta.update(password.convert_password(ctxt,
                                                      base64.b64encode(enc)))
            self.virtapi.instance_update(ctxt, self.instance['uuid'],
                                         {'system_metadata': sys_meta})

        return resp['message']
开发者ID:JacobMulero,项目名称:nova,代码行数:55,代码来源:agent.py


示例5: _test_ssh_encrypt_decrypt_text

 def _test_ssh_encrypt_decrypt_text(self, key):
     enc = crypto.ssh_encrypt_text(self.pubkey, self.text)
     self.assertIsInstance(enc, bytes)
     # Comparison between bytes and str raises a TypeError
     # when using python3 -bb
     if six.PY2:
         self.assertNotEqual(enc, self.text)
     result = self._ssh_decrypt_text(self.prikey, enc)
     self.assertIsInstance(result, bytes)
     if six.PY3:
         result = result.decode('utf-8')
     self.assertEqual(result, self.text)
开发者ID:B3n0n3,项目名称:nova,代码行数:12,代码来源:test_crypto.py


示例6: test_ssh_encrypt_decrypt_text

 def test_ssh_encrypt_decrypt_text(self):
     enc = crypto.ssh_encrypt_text(self.pubkey, self.text)
     self.assertNotEqual(enc, self.text)
     result = self._ssh_decrypt_text(self.prikey, enc)
     self.assertEqual(result, self.text)
开发者ID:angdraug,项目名称:nova,代码行数:5,代码来源:test_crypto.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python db.agent_build_get_by_triple函数代码示例发布时间:2022-05-27
下一篇:
Python crypto.revoke_cert函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap