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


Python sshcontrol.SSHControl类代码示例

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


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

示例1: test_all_users_can_connect_via_ssh_without_password

    def test_all_users_can_connect_via_ssh_without_password(self):
        """
        Summary:     Check if all users can connect via ssh without password
        Expected: 1. Connection to the image via ssh using root user without providing a password should NOT be allowed.
                  2. Connection to the image via ssh using tester user without providing a password should be allowed.
        Product:     oe-core
        Author:      Ionut Chisanovici <[email protected]>
        AutomatedBy: Daniel Istrate <[email protected]>
        """

        features = 'EXTRA_IMAGE_FEATURES = "ssh-server-openssh allow-empty-password allow-root-login"\n'
        features += 'INHERIT += "extrausers"\n'
        features += 'EXTRA_USERS_PARAMS = "useradd -p \'\' {}; usermod -s /bin/sh {};"'.format(self.test_user, self.test_user)
        self.write_config(features)

        # Build a core-image-minimal
        bitbake('core-image-minimal')

        with runqemu("core-image-minimal") as qemu:
            # Attempt to ssh with each user into qemu with empty password
            for user in [self.root_user, self.test_user]:
                ssh = SSHControl(ip=qemu.ip, logfile=qemu.sshlog, user=user)
                status, output = ssh.run("true")
                if user == 'root':
                    self.assertNotEqual(status, 0, 'ssh to user root was allowed when it should not have been')
                else:
                    self.assertEqual(status, 0, 'ssh to user tester failed with %s' % output)
开发者ID:openembedded,项目名称:openembedded-core,代码行数:27,代码来源:imagefeatures.py

示例2: FakeTarget

class FakeTarget(object):
    def __init__(self, d):
        self.connection = None
        self.ip = None
        self.server_ip = None
        self.datetime = time.strftime('%Y%m%d%H%M%S',time.gmtime())
        self.testdir = d.getVar("TEST_LOG_DIR", True)
        self.pn = d.getVar("PN", True)

    def exportStart(self):
        self.sshlog = os.path.join(self.testdir, "ssh_target_log.%s" % self.datetime)
        sshloglink = os.path.join(self.testdir, "ssh_target_log")
        if os.path.lexists(sshloglink):
            os.remove(sshloglink)
        os.symlink(self.sshlog, sshloglink)
        print("SSH log file: %s" %  self.sshlog)
        self.connection = SSHControl(self.ip, logfile=self.sshlog)

    def run(self, cmd, timeout=None):
        return self.connection.run(cmd, timeout)

    def copy_to(self, localpath, remotepath):
        return self.connection.copy_to(localpath, remotepath)

    def copy_from(self, remotepath, localpath):
        return self.connection.copy_from(remotepath, localpath)
开发者ID:agangidi53,项目名称:openbmc,代码行数:26,代码来源:runexported.py

示例3: test_non_root_user_can_connect_via_ssh_without_password

    def test_non_root_user_can_connect_via_ssh_without_password(self):
        """
        Summary: Check if non root user can connect via ssh without password
        Expected: 1. Connection to the image via ssh using root user without providing a password should be allowed.
                  2. Connection to the image via ssh using tester user without providing a password should be allowed.
        Product: oe-core
        Author: Ionut Chisanovici <[email protected]>
        AutomatedBy: Daniel Istrate <[email protected]>
        """

        features = 'EXTRA_IMAGE_FEATURES = "ssh-server-openssh empty-root-password allow-empty-password"\n'
        features += 'INHERIT += "extrausers"\n'
        features += "EXTRA_USERS_PARAMS = \"useradd -p '' {}; usermod -s /bin/sh {};\"".format(
            self.test_user, self.test_user
        )

        # Append 'features' to local.conf
        self.append_config(features)

        # Build a core-image-minimal
        bitbake("core-image-minimal")

        with runqemu("core-image-minimal", self) as qemu:
            # Attempt to ssh with each user into qemu with empty password
            for user in [self.root_user, self.test_user]:
                ssh = SSHControl(ip=qemu.ip, logfile=qemu.sshlog, user=user)
                status, output = ssh.run("true")
                self.assertEqual(status, 0, "ssh to user %s failed with %s" % (user, output))
开发者ID:shgoupf,项目名称:openbmc,代码行数:28,代码来源:imagefeatures.py

示例4: exportStart

 def exportStart(self):
     self.sshlog = os.path.join(self.testdir, "ssh_target_log.%s" % self.datetime)
     sshloglink = os.path.join(self.testdir, "ssh_target_log")
     if os.path.lexists(sshloglink):
         os.remove(sshloglink)
     os.symlink(self.sshlog, sshloglink)
     print("SSH log file: %s" %  self.sshlog)
     self.connection = SSHControl(self.ip, logfile=self.sshlog)
开发者ID:agangidi53,项目名称:openbmc,代码行数:8,代码来源:runexported.py


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