Processes SSH keys
        :param data:
        :param name:
        :return:
185305
def process_ssh(self, data, name):
        
        if data is None or len(data) == 0:
            return

        ret = []
        try:
            lines = [x.strip() for x in data.split(b'\n')]
            for idx, line in enumerate(lines):
                ret.append(self.process_ssh_line(line, name, idx))

        except Exception as e:
            logger.debug('Exception in processing SSH public key %s : %s' % (name, e))
            self.trace_logger.log(e)
        return ret
742383
def ssh_client(host, username=None, password=None, **kwargs):
    
    client = paramiko.SSHClient()
    # save hostname and username on the instance - this is a ugly hack
    # but I don't see any other way to do that for now. Note that
    # this is only used for SshSession.__str__.
    client.hostname = host
    client.username = username
    if username is not None:
        kwargs['username'] = username
    if password is not None:
        kwargs['password'] = password
    if username is not None and password is not None:
        client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
        kwargs.setdefault('look_for_keys', False)
    client.connect(host, **kwargs)
    return client
1007253
def create(cls, name, value):
        
        sshkey_params = {
            'name': name,
            'value': value,
        }

        result = cls.call('hosting.ssh.create', sshkey_params)
        return result
946094
def ssh_cmd(self, name, ssh_command):
        
        if not self.container_exists(name=name):
            exit("Unknown container {0}".format(name))

        if not self.container_running(name=name):
            exit("Container {0} is not running".format(name))

        ip = self.get_container_ip(name)
        if not ip:
            exit("Failed to get network address for "
                 "container {0}".format(name))
        if ssh_command:
            ssh.do_cmd('root', ip, 'password', " ".join(ssh_command))
        else:
            ssh.launch_shell('root', ip, 'password')
188051
def get_keys_from_ldap(self, username=None):
        
        result_dict = {}
        filter = ['(sshPublicKey=*)']
        if username is not None:
            filter.append('(uid={})'.format(username))
        attributes = ['uid', 'sshPublicKey']
        results = self.client.search(filter, attributes)
        for result in results:
            result_dict[result.uid.value] = result.sshPublicKey.values
        return result_dict
475310
def process_new_command_data(new_data)
      @data ||= []

      key = row_key new_data
      command = new_data.delete(:command) || new_data.delete('command')

      send "process_#{command.to_s.downcase}_command", key, new_data
    end
209729
def strlen(self, name):
        
        with self.pipe as pipe:
            return pipe.strlen(self.redis_key(name))
229284
def sshfp_data(key_t, hash_t, pub):
    '''
    
    '''
    key_t = RFC.validate(key_t, RFC.SSHFP_ALGO, 'in')
    hash_t = RFC.validate(hash_t, RFC.SSHFP_HASH)

    hasher = hashlib.new(hash_t)
    hasher.update(
        base64.b64decode(pub)
    )
    ssh_fp = hasher.hexdigest()

    return _rec2data(key_t, hash_t, ssh_fp)
1364524
def ssh(name):
    """"""
    env.host_string = lib.get_env_host_string()
    print("\nExecuting the command '{0}' on node {1}...".format(
          name, env.host_string))
    # Execute remotely using either the sudo or the run fabric functions
    with settings(hide("warnings"), warn_only=True):
        if name.startswith("sudo "):
            sudo(name[5:])
        else:
            run(name)
718649
async def remove_ssh_key(self, user, key):
        
        key_facade = client.KeyManagerFacade.from_connection(self.connection())
        key = base64.b64decode(bytes(key.strip().split()[1].encode('ascii')))
        key = hashlib.md5(key).hexdigest()
        key = ':'.join(a + b for a, b in zip(key[::2], key[1::2]))
        await key_facade.DeleteKeys([key], user)
541774
def dump(self, name):
        
        with self.pipe as pipe:
            return pipe.dump(self.redis_key(name))
950597
def get_data(context, id, keys):
    

    if keys:
        keys = keys.split(',')
    result = remoteci.get_data(context, id=id, keys=keys)
    utils.format_output(result, context.format, keys)
1029420
def zrevrank(self, name, value):
        
        with self.pipe as pipe:
            return pipe.zrevrank(self.redis_key(name),
                                 self.valueparse.encode(value))
52554
def copySshKeys(self, keyName):
        
        if keyName == 'core':
            return # No point.

        # Make sure that keys are there.
        self._waitForSSHKeys(keyName=keyName)

        # copy keys to core user so that the ssh calls will work
        # - normal mechanism failed unless public key was in the google-ssh format
        # - even so, the key wasn't copied correctly to the core account
        keyFile = '/home/%s/.ssh/authorized_keys' % keyName
        self.sshInstance('/usr/bin/sudo', '/usr/bin/cp', keyFile, '/home/core/.ssh', user=keyName)
        self.sshInstance('/usr/bin/sudo', '/usr/bin/chown', 'core',
                         '/home/core/.ssh/authorized_keys', user=keyName)
1183558
def sshagent_run(cmd):
    
    # Handle context manager modifications
    wrapped_cmd = _prefix_commands(_prefix_env_vars(cmd), 'remote')
    try:
        host, port = env.host_string.split(':')
        return local(
            u"ssh -p %s -A -o StrictHostKeyChecking=no %s@%s '%s'" % (
                port, env.user, host, wrapped_cmd
            )
        )
    except ValueError:
        return local(
            u"ssh -A -o StrictHostKeyChecking=no %s@%s '%s'" % (
                env.user, env.host_string, wrapped_cmd
            )
        )
1166982
def hlen(self, name):
        
        with self.pipe as pipe:
            return pipe.hlen(self.redis_key(name))
240890
def update(self, data):
        
        result = None
        if data:
            _dumps = self._dumps
            data = {
                key: _dumps(value)
                for key, value in data.items()}
            result = self._client.hmset(self.key_prefix, data)
        return result