Пример #1
0
def remove_user(username):
    db = AuthorizedKeysDB()
    try:
        db.remove_user(username)
    except KeyError:
        subssh.errln("No such user '%s'" % username)
    else:
        db.commit()
    db.close()
Пример #2
0
def rewrite_authorized_keys():
    db = AuthorizedKeysDB()
    db.commit()
    db.close()
    return 0
Пример #3
0
        if len(e.args) > 1:
            subssh.errln(e.args[1])
        else:
            subssh.errln(e.args[0])
        return 1

    exit_status = 0

    db = AuthorizedKeysDB()
    try:
        db.add_key_from_str(username, key, comment)
    except (PubKeyException, AuthorizedKeysException), e:
        subssh.errln(e.args[0])
        exit_status = 1
    else:
        db.commit()
    db.close()


    return exit_status

def list_keys(username):
    db = AuthorizedKeysDB(disable_lock=True)
    try:
        subuser = db.subusers[username]
    except KeyError:
        subssh.writeln("%s has no keys" % username)
    else:
        for i, (key, (type, comment)) in enumerate(subuser.pubkeys.items()):
            subssh.writeln("%s. %s key: %s %s" %
                          (i+1, comment, type , key))