Смена стандартного пароля администратора
06 октября 2026
ID 320883
Для обеспечения базового уровня безопасности развернутой системы смените стандартный пароль администратора с помощью скрипта управления учетными данными.
Для смены пароля администратора вы можете использовать скрипт на python:
change_password.py
import requests
import sys
import getpass
import json
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
ip = sys.argv[1]
sess = requests.Session()
sess.verify = False
username = input("Enter the orchestrator user login: ")
password = getpass.getpass(f"Enter the current password for the user {username}: ")
try:
response=sess.get('https://'+ ip +'/api/core/users/current')
response=sess.post(('https://'+ ip +'/api/authentication'), data={'j_username': username, 'j_password': password},headers={'X-CSRF-TOKEN': sess.cookies['CSRF-TOKEN']})
if response.status_code != 200:
if response.status_code == 403 and response.json()[0]['code'] == "required_2fa_code":
secFA_code = getpass.getpass(f"Enter the two-factor authentication code: ")
response=sess.post(('https://'+ ip +'/api/authentication'), data={'j_username': username, 'j_password': password, 'code': secFA_code},headers={'X-CSRF-TOKEN': sess.cookies['CSRF-TOKEN']})
if response.status_code != 200:
print(f"Authentication failed.")
sys.exit(1)
else:
print(f"Authentication failed.")
sys.exit(1)
except Exception as e:
print(f"Authentication failed. Error: {e}")
sys.exit(1)
sess.get('https://'+ ip +'/api/core/users/current')
sess.headers.update({'Accept': 'application/json','content-type': 'application/json','X-CSRF-TOKEN': sess.cookies['CSRF-TOKEN']})
response.status_code = 400
while response.status_code != 200:
new_password = getpass.getpass(f"Enter a new password for the user {username}: ")
new_password2 = getpass.getpass(f"Repeat the new password for the user {username}: ")
if new_password != new_password2:
print()
print("The new password you entered does not match")
print()
else:
payload = {"password": new_password}
response=sess.post(('https://'+ ip +'/api/core/users/password/validate'), data=json.dumps(payload),headers={'X-CSRF-TOKEN': sess.cookies['CSRF-TOKEN']})
if response.status_code != 200:
print()
print("Weak password!")
print()
payload = {"password": new_password}
try:
response=sess.put(('https://'+ ip +'/api/core/users/current/password'), data=json.dumps(payload),headers={'X-CSRF-TOKEN': sess.cookies['CSRF-TOKEN']})
if response.status_code != 200:
print("Failed to change password!")
elif response.status_code == 200:
print()
print("Password successfully changed!")
print()
except Exception as e:
print("Failed to change password", e)