ssh_manager.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:STF 作者: nokia 项目源码 文件源码
def _checkAccessUsingKey(self, host, user, port=SSH_DEFAULT_PORT):
        """
        check if we have SSH access via user by using SSH keys ?
        Having an AuthenticatioException is one of the standard ways.

        :param Lab host: hostname
        :param str user: user to login
        :return: None if no connection. Returns instance of SSH connection if OK
        :rtype: None/object

        >>> self._checkAccessUsingKey(host, user, port=SSH_DEFAULT_PORT)
        """
        #client = paramiko.SSHClient()
        client = paramiko.client.SSHClient()
        client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
        #  to ignore user .ssh homedir keys : use those options  allow_agent=False, look_for_keys=False)
        # CAUTION with those option : exception is SSHException (instead of AuthenticationException)
        client.connect(host, port, user, key_filename=self.privateKey)
        client.get_transport().set_keepalive(self.__class__.defaultHeartbeat)
        return client
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号