标签搜索

使用管理员登录 JumpServer 堡垒机时遇到错误的处理

cicaba
2025-09-22 / 0 评论 / 1 阅读 / 正在检测是否收录...
# 进入容器内部
docker exec -it jumpserver /bin/bash

# 进入目录
cd /opt/jumpserver/apps/

# 如果遇到错误:ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?
# 可以执行以下命令激活 python 环境(可能 v4 容器需要)
source /opt/py3/bin/activate

# 进入 python 环境
python manage.py shell
# 或
python3 manage.py shell

# 重置用户密码
from users.models import User
u = User.objects.get(username='admin')
u.reset_password('admin')
u.save()

# 解锁登录限制
from django.core.cache import cache
cache.delete_pattern('_LOGIN_BLOCK_*')
cache.delete_pattern('_LOGIN_LIMIT_*')

# 启用禁用的用户:
from users.models import User
User.objects.filter(username='admin').update(is_active=True)
0

评论 (0)

取消