當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。