'Returns dictionary where keys are remote usernames and values are
pwd.struct_passwd objects from the standard pwd module
key_by_uid=True will use the integer uid as the returned dictionary\'s
keys instead of the user\'s login name'

def get_user_map(self, key_by_uid=False):

    etc_passwd = self.ssh.remote_file('/etc/passwd', 'r')
    users = [l.strip().split(':') for l in etc_passwd.readlines()]
    etc_passwd.close()
    user_map = {}
    for user in users:
        (name, passwd, uid, gid, gecos, home, shell) = user
        uid = int(uid)
        gid = int(gid)
        key = name
        if key_by_uid:
            key = uid
        user_map[key] = utils.struct_passwd([name, passwd, uid, gid, gecos, home, shell])
    return user_map
