Как продлить срок действия пароля и где следить за его актуальностью?
Давно как-то ставил Oracle 11 себе на виртуальную машину. А сегодня понадобилось работать опять с системой. Попытался подключиться, но мне говорят срок действия пароля истек на пользователя system . Как можно исправить эту проблему? Где надо продлевать пароль и следить за его актуальностью?
Отслеживать
51.6k 201 201 золотой знак 63 63 серебряных знака 245 245 бронзовых знаков
задан 13 мар 2014 в 8:51
IntegralAL IntegralAL
2,699 5 5 золотых знаков 60 60 серебряных знаков 105 105 бронзовых знаков
с локальной машины можно всегда зайти под встроеной учетной записью системного администратора (as sysdba): community.oracle.com/thread/347053
13 мар 2014 в 8:56
а что с учетными записями пользователей? Мне нужно через system зайти, а не лишь бы только зайти в базу.
13 мар 2014 в 9:06
а дальше как-то так: docs.oracle.com/cd/B19306_01/server.102/b14200/…
13 мар 2014 в 9:14
@jmu, то что вы указали в первом сообщение будет работать для 11g? Не поверю что в оракле такая дыра была, чтобы без пароля входить под админом. гранты и привилегии временные что ли? Почему пароли устаревают? Вопросы без ответов.
13 мар 2014 в 9:33
> Не поверю что в оракле такая дыра была, чтобы без пароля входить под админом. проблема не в том что системный администратор может войти в субд а в в этом: > потому что любой злоумышленник может сесть за компьютер админа если вы не можете защитить пк от злоумышленника парится по поводу пароля на субд бесполезно
14 мар 2014 в 23:37
1 ответ 1
Сортировка: Сброс на вариант по умолчанию
Надо зайти на сервер БД под уч. записью, входящей в группу администраторов БД,
обычно dba (на Windows ORA_DBA ). Если на сервере несколько инстанций БД, то надо убедится, что переменные окружения ORACLE_SID , ORACLE_HOME установлены правильно.
Зайти в SQL*Plus, посмотреть, у кого истёк пароль, продлить его (по умолчанию на 180 дней):
$ sqlplus / as sysdba SQL> select username, account_status, lock_date, expiry_date 2 from dba_users where account_status like 'EXPIRED%'; USERNAME ACCOUNT_STATUS LOCK_DATE EXPIRY_DATE ---------------- ---------------- --------------- --------------- ANONYMOUS EXPIRED & LOCKED 20190417T020418 20190417T020418 HR EXPIRED & LOCKED 20200615T202643 20200615T202643 SQL> alter user hr identified by hr account unlock; User altered.
Oracle password expired как убрать
В Oracle 11g при попытке соединения с БД появляется сообщение об ошибке:
ORA-28002: the password will expire within XXX days
Вот цитата из документации:
ORA-28002: the password will expire within string days
Cause: The user’s account is about to about to expire and the password needs to be changed
Action: change the password or contact the DBA
Причина:
В версии Oracle 11g изменился профиль для пользователей по умолчанию (DEFAULT). В основном изменились параметры имеющие отношения к паролю. В Oracle 10g все они были равны UNLIMITED, в Oracle 11g они получили конкретные значения. Именно по этому периодически возникает ORA-28002.
©Bobrovsky Dmitry
PASSWORD_LIFE_TIME = 180
В течении PASSWORD_LIFE_TIME дней (180) пользователь может использовать текущий пароль.
PASSWORD_GRACE_TIME = 7
Когда период PASSWORD_LIFE_TIME (180 дней) заканчивается, пользователю дается еще PASSWORD_GRACE_TIME (7 дней) в течении которых он должен изменить пароль. Потом учетная запись блокируется.
©Bobrovsky Dmitry
FAILED_LOGIN_ATTEMPTS = 10
Столько неудачных попыток дается пользователю соединиться с БД прежде чем заблокировать учетную запись. (Неудача обычно бывает из-за неправильного пароля = Нажат CapsLock или неправильная раскладка клавиатуры или (для 11g) неправильный регистр пароля).
PASSWORD_LOCK_TIME = 1
После FAILED_LOGIN_ATTEMPTS (10) неудачных попыток, учетная запись будет заблокирована на PASSWORD_LOCK_TIME дней (на 1 день).
Чтобы посмотреть параметры профиля, выполните запрос
SELECT resource_name, resource_type, LIMIT FROM dba_profiles WHERE profile = 'DEFAULT';
Решения:
— Можно подчиниться параметрам безопасности. Тогда каждый пользователь каждые 180 дней должен менять пароль.
Dmitry Bobrovsky
— Можно изменить параметры профиля DEFAULT или создать свой профиль с параметрами удобными для вас и назначить его пользователям.
Dmitry Bobrovsky
— Что бы полностью отключить проверку длительности использования пароля, нужно установить параметр PASSWORD_LIFE_TIME в UNLIMITED. И обязательно изменить пароль! (можно изменить фиктивно, т.е. оставить тот же, но процедуру изменения пароля нужно провести).
ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED; ALTER USER XXX IDENTIFIED BY "xxx";
Чтобы изменить пароль сразу у множества пользователей можно использовать процедуру.
Значения параметр astatus возможно посмотреть так:
select * from sys.user_astatus_map;
STATUS# STATUS
0 OPEN
1 EXPIRED
2 EXPIRED(GRACE)
4 LOCKED(TIMED)
8 LOCKED
5 EXPIRED & LOCKED(TIMED)
6 EXPIRED(GRACE) & LOCKED(TIMED)
9 EXPIRED & LOCKED
10 EXPIRED(GRACE) & LOCKED
connect / as sysdba spool runme.sql set serveroutput on size 200000 declare stmt varchar2(200); v_old_hash user$.password%type; v_new_hash user$.spare4%type; v_hash varchar2(200); begin for user_rec in (select name, password, spare4 from user$ where type#=1 and astatus in(1,2)) loop v_old_hash := user_rec.password; v_new_hash := user_rec.spare4; if not ((v_old_hash is null) and (v_new_hash is null)) then if (v_new_hash is null) then if v_old_hash <> 'EXTERNAL' then v_hash := ''''||v_old_hash||''''; else goto end_loop; end if; end if; if (v_old_hash is null) then v_hash := ''''||v_new_hash||''''; end if; if ((v_old_hash is not null) and (v_new_hash is not null)) then v_hash := ''''||v_old_hash||';'||v_new_hash||''''; end if; stmt := 'alter user '||user_rec.name||' identified by values'||v_hash; end if; dbms_output.put_line(stmt||';'); <> null; end loop; end; / spool off
Oracle password expired как убрать
Перестало работать приложение, использующее СУБД Oracle XE, в логе сообщение об истечении срока действия пароля: ORA-28001: the password has expired. При чем, было неизвестно под каким пользователем коннектится приложение. Но ясно, что искать надо просроченные пароли.
Приконнектиться к базе как супер админ:
conn / as sysdba
Посмотреть пользователей с истекшими паролями:
SQL> SELECT USERNAME,ACCOUNT_STATUS FROM dba_users WHERE ACCOUNT_STATUS LIKE '%EXPIRED%';
USERNAME ACCOUNT_STATUS
------------------------------ --------------------------------
DIP EXPIRED > LOCKED
ORACLE_OCM EXPIRED > LOCKED
DBSNMP EXPIRED > LOCKED
APPQOSSYS EXPIRED > LOCKED
ORAUSER EXPIRED > LOCKED
Стало ясно, что искомый пользователь ORAUSER. Теперь надо его разлочить и сменить\переназначить пароль:
SQL> ALTER USER orauser ACCOUNT UNLOCK;
User altered.
SQL> ALTER USER orauser IDENTIFIED BY newpass;
User altered.
Проверить статус и дополнительно посмотреть дату истечения пароля:
SQL> SELECT USERNAME,ACCOUNT_STATUS,EXPIRY_DATE FROM dba_users WHERE USERNAME LIKE '%ORAUSER%';
USERNAME ACCOUNT_STATUS EXPIRY_DA
------------------------------ -------------------------------- ---------
ORAUSER OPEN 03-JAN-15
Видно, что учетка работает, но 3 января срок действия пароля снова истечет. Чтобы этого не происходило надо отключить данную возможность. Для этого надо узнать к какому профилю относится пользователь и отключить истечение времени действия пароля для этого профиля:
SQL> SELECT USERNAME,PROFILE from dba_users WHERE USERNAME LIKE '%ORAUSER%';
USERNAME PROFILE
------------------------------ ------------------------------
ORAUSER ORAPROFILE
SQL> ALTER PROFILE oraprofile LIMIT PASSWORD_LIFE_TIME UNLIMITED;
Profile altered.
Убедиться что все сработало. Поле EXPIRY_DATE должно быть пустым:
SQL> SELECT USERNAME,ACCOUNT_STATUS,EXPIRY_DATE FROM dba_users WHERE USERNAME LIKE '%ORAUSER%';
USERNAME ACCOUNT_STATUS EXPIRY_DA
------------------------------ -------------------------------- ---------
ORAUSER OPEN
How do I turn off Oracle password expiration?
I’m using Oracle for development. The password for a bootstrap account that I always use to rebuild my database has expired. How do I turn off password expiration for this user (and all other users) permanently? I’m using Oracle 11g, which has passwords expire by default.
Josh Kodroff
asked Jul 8, 2009 at 2:32
Josh Kodroff Josh Kodroff
27.5k 27 27 gold badges 95 95 silver badges 148 148 bronze badges
I think you might be better off asking this on serverfault.com. I’m not going to force it because you did say you’re using it for development, and I think there’s still a chance someone here will know and/or others here might benefit from this information.
Jul 8, 2009 at 2:58
I think I’ll do just that. I was debating which site it was more appropriate for, since it’s a basic database question and not so much a DBA thing.
Jul 8, 2009 at 11:58
Not sure what the dupe policy is for cross-site questions, but here’s the link: serverfault.com/questions/37622/…
Jul 8, 2009 at 12:04
6 Answers 6
To alter the password expiry policy for a certain user profile in Oracle first check which profile the user is using:
select profile from DBA_USERS where username = '';
Then you can change the limit to never expire using:
alter profile limit password_life_time UNLIMITED;
If you want to previously check the limit you may use:
select resource_name,limit from dba_profiles where profile='';
3,561 28 28 gold badges 39 39 silver badges 38 38 bronze badges
answered Jul 21, 2011 at 13:47
Pedro Carriço Pedro Carriço
4,068 2 2 gold badges 16 16 silver badges 11 11 bronze badges
This altered the profile. However, I have users whose passwords are set to expire because the default profile had it as such when they were created. How do I alter these user accounts so the password doesn’t expire?
May 11, 2012 at 20:41
select username,expiry_date,account_status from dba_users; to view the account_status. for those expiring account, you may need to reset the password once for the last time.
Dec 7, 2012 at 1:59
alter user aaa account unlock;
Oct 9, 2013 at 21:23
For completeness, if you need to change a user to another profile: ALTER USER Bob PROFILE MyNonExpiringProfile; .
– user565869
May 13, 2015 at 18:28
no rows selected on the query «select profile from DBA_USERS where username = ‘
Oct 14, 2019 at 6:25
For development you can disable password policy if no other profile was set (i.e. disable password expiration in default one):
ALTER PROFILE "DEFAULT" LIMIT PASSWORD_VERIFY_FUNCTION NULL;
Then, reset password and unlock user account. It should never expire again:
alter user user_name identified by new_password account unlock;
answered Sep 11, 2013 at 19:09
1,434 1 1 gold badge 10 10 silver badges 9 9 bronze badges
As the other answers state, changing the user’s profile (e.g. the ‘DEFAULT’ profile) appropriately will lead to passwords, that once set, will never expire.
However, as one commenter points out, passwords set under the profile’s old values may already be expired, and (if after the profile’s specified grace period) the account locked.
The solution for expired passwords with locked accounts (as provided in an answering comment) is to use one version of the ALTER USER command:
ALTER USER xyz_user ACCOUNT UNLOCK;
However the unlock command only works for accounts where the account is actually locked, but not for those accounts that are in the grace period, i.e. where the password is expired but the account is not yet locked. For these accounts the password must be reset with another version of the ALTER USER command:
ALTER USER xyz_user IDENTIFIED BY new_password;
Below is a little SQL*Plus script that a privileged user (e.g. user ‘SYS’) can use to reset a user’s password to the current existing hashed value stored in the database.
EDIT: Older versions of Oracle store the password or password-hash in the pword column, newer versions of Oracle store the password-hash in the spare4 column. Script below changed to collect the pword and spare4 columns, but to use the spare4 column to reset the user’s account; modify as needed.
REM Tell SQL*Plus to show before and after versions of variable substitutions. SET VERIFY ON SHOW VERIFY REM Tell SQL*Plus to use the ampersand '&' to indicate variables in substitution/expansion. SET DEFINE '&' SHOW DEFINE REM Specify in a SQL*Plus variable the account to 'reset'. REM Note that user names are case sensitive in recent versions of Oracle. REM DEFINE USER_NAME = 'xyz_user' REM Show the status of the account before reset. SELECT ACCOUNT_STATUS, TO_CHAR(LOCK_DATE, 'YYYY-MM-DD HH24:MI:SS') AS LOCK_DATE, TO_CHAR(EXPIRY_DATE, 'YYYY-MM-DD HH24:MI:SS') AS EXPIRY_DATE FROM DBA_USERS WHERE USERNAME = '&USER_NAME'; REM Create SQL*Plus variable to hold the existing values of the password and spare4 columns. DEFINE OLD_SPARE4 = "" DEFINE OLD_PASSWORD = "" REM Tell SQL*Plus where to store the values to be selected with SQL. REM Note that the password hash value is stored in spare4 column in recent versions of Oracle, REM and in the password column in older versions of Oracle. COLUMN SPARE4HASH NEW_VALUE OLD_SPARE4 COLUMN PWORDHASH NEW_VALUE OLD_PASSWORD REM Select the old spare4 and password columns as delimited strings SELECT '''' || SPARE4 || '''' AS SPARE4HASH, '''' || PASSWORD || '''' AS PWORDHASH FROM SYS.USER$ WHERE NAME = '&USER_NAME'; REM Show the contents of the SQL*Plus variables DEFINE OLD_SPARE4 DEFINE OLD_PASSWORD REM Reset the password - Older versions of Oracle (e.g. Oracle 10g and older) REM ALTER USER &USER_NAME IDENTIFIED BY VALUES &OLD_PASSWORD; REM Reset the password - Newer versions of Oracle (e.g. Oracle 11g and newer) ALTER USER &USER_NAME IDENTIFIED BY VALUES &OLD_SPARE4; REM Show the status of the account after reset SELECT ACCOUNT_STATUS, TO_CHAR(LOCK_DATE, 'YYYY-MM-DD HH24:MI:SS') AS LOCK_DATE, TO_CHAR(EXPIRY_DATE, 'YYYY-MM-DD HH24:MI:SS') AS EXPIRY_DATE FROM DBA_USERS WHERE USERNAME = '&USER_NAME';