Linux no shadow file

Для чего нужен файл /etc/shadow

В системах Linux можно использовать несколько различных схем аутентификации. Наиболее часто используемая и стандартная схема — аутентификация по файлам /etc/passwd и /etc/shadow .

/etc/shadow — это текстовый файл, содержащий информацию о паролях пользователей системы. Он принадлежит пользователю root и теневой группе и имеет 640 разрешений .

Формат /etc/shadow

Файл /etc/shadow содержит по одной записи в каждой строке, каждая из которых представляет учетную запись пользователя. Вы можете просмотреть содержимое файла с помощью текстового редактора или такой команды, как cat :

Обычно первая строка описывает пользователя root, за которым следуют учетные записи системного и обычного пользователя. Новые записи добавляются в конец файла.

Каждая строка файла /etc/shadow содержит девять полей, разделенных запятыми:

  1. Имя пользователя. Строка, которую вы вводите при входе в систему. Учетная запись пользователя, существующая в системе.
  2. Зашифрованный пароль. Пароль использует $type$salt$hashed формат $type$salt$hashed . $type — это алгоритм криптографического хеширования метода и может иметь следующие значения:
    • $1$ — 5 MDL
    • $2a$ — Blowfish
    • $2y$ — Eksblowfish
    • $5$ — SHA-256
    • $6$ — SHA-512

Если в поле пароля есть звездочка ( * ) или восклицательный знак ( ! ), Пользователь не сможет войти в систему, используя аутентификацию по паролю. Другие методы входа в систему, такие как аутентификация на основе ключей или переключение на пользователя , по-прежнему разрешены.

В старых системах Linux зашифрованный пароль пользователя хранился в /etc/passwd .

  • Последнее изменение пароля. Это дата последней смены пароля. Число дней отсчитывается с 1 января 1970 года (дата эпохи).
  • Минимальный возраст пароля. Количество дней, которое должно пройти, прежде чем можно будет изменить пароль пользователя. Обычно он равен нулю, что означает отсутствие минимального возраста пароля.
  • Максимальный возраст пароля. Количество дней после смены пароля пользователя. По умолчанию этот номер установлен на 99999 .
  • Период предупреждения. Количество дней до истечения срока действия пароля, в течение которых пользователя предупреждают о необходимости изменения пароля.
  • Период бездействия. Количество дней после истечения срока действия пароля пользователя до отключения учетной записи пользователя. Обычно это поле пусто.
  • Дата окончания срока. Дата, когда учетная запись была отключена. Он представлен как дата эпохи.
  • Не используется. Это поле игнорируется. Он зарезервирован для использования в будущем.
  • Файл /etc/shadow не следует редактировать вручную, если вы не знаете, что делаете. Всегда используйте команду, предназначенную для этой цели. Например, чтобы изменить пароль пользователя, используйте команду passwd , а чтобы изменить информацию об устаревании пароля, используйте команду chage .

    Пример записи

    Давайте посмотрим на следующий пример:

    Запись выше содержит информацию о пароле пользователя linuxize:

    • Пароль зашифрован с помощью SHA-512 (пароль усечен для лучшей читаемости).
    • Последний раз пароль менялся 23 апреля 2019 г. — 18009 .
    • Нет минимального возраста пароля.
    • Пароль необходимо менять не реже, чем каждые 120 дней.
    • Пользователь получит предупреждающее сообщение за семь дней до истечения срока действия пароля.
    • Если пользователь не попытается войти в систему через 14 дней после истечения срока действия пароля, учетная запись будет отключена.
    • Срок действия учетной записи отсутствует.

    Выводы

    В /etc/shadow хранятся записи о зашифрованных паролях пользователей, а также другая информация, связанная с паролями.

    Если у вас есть какие-либо вопросы или отзывы, не стесняйтесь оставлять комментарии.

    Источник

    Understanding /etc/shadow file format on Linux

    Understanding /etc/shadow file fields/format

    Basically, the /etc/shadow file stores secure user account information. All fields are separated by a colon ( : ) symbol. It contains one entry per line for each user listed in /etc/passwd file. Generally, shadow file entry looks as follows (click to enlarge image):

    (Fig.01: /etc/shadow file fields)

    1. Username : It is your login name.
    2. Password : It is your encrypted password. The password should be minimum 8-12 characters long including special characters, digits, lower case alphabetic and more. Usually password format is set to $id$salt$hashed , The $id is the algorithm used On GNU/Linux as follows:
      1. $1$ is MD5
      2. $2a$ is Blowfish
      3. $2y$ is Blowfish
      4. $5$ is SHA-256
      5. $6$ is SHA-512
    3. Last password change (lastchanged) : Days since Jan 1, 1970 that password was last changed
    4. Minimum : The minimum number of days required between password changes i.e. the number of days left before the user is allowed to change his/her password
    5. Maximum : The maximum number of days the password is valid (after that user is forced to change his/her password)
    6. Warn : The number of days before password is to expire that user is warned that his/her password must be changed
    7. Inactive : The number of days after password expires that account is disabled
    8. Expire : days since Jan 1, 1970 that account is disabled i.e. an absolute date specifying when the login may no longer be used.
    Читайте также:  Uname command in windows

    A note about password ageing

    The last 6 fields provides password aging and account lockout features. You need to use the chage command to setup password aging. According to man page of shadow – the password field must be filled. The encrypted password consists of 13 to 24 characters from the 64 character alphabet a through z, A through Z, 0 through 9, \. and /. Optionally it can start with a “ $ ” character. This means the encrypted password was generated using another (not DES) algorithm. For example if it starts with “ $1$ ” it means the MD5-based algorithm was used. If a password field which starts with a exclamation mark ( ! ) means that the password is locked. The remaining characters on the line represent the password field before the password was locked.

    How do I change the password?

    Use the following syntax to change your own password:
    $ passwd
    See passwd command tutorial page for more information.

    How do I change the password for other users?

    How do I change or set password ageing information?

    To change user password expiry information use the chage command on Linux. The syntax is (again you must be root to set the password again) as follows:

    Источник

    Linux no shadow file

    Традиционные Unix системы хранят данные о пользователях вместе с зашифрованным паролем в текстовом файле « /etc/passwd ». Поскольку этот файл используется многими инструментальными средствами (типа «ls») чтобы отобразить владельца файла и другие подобные сведения, файл должен быть открыт на чтение для всех, что, конечно, дает отличный шанс хакерам.

    Другой метод хранения информации, тот, который я всегда использую, затенение паролей. Как и раньше, есть файл /etc/passwd с данными о пользователях. Однако, вместо паролей ставится символ “x”, а пароли хранятся отдельно в файле « /etc/shadow », в котором хранятся зашифрованные пароли и некоторая дополнительная информация о паролях. Файл /etc/shadow доступен для чтения только root, что повышает защиту.

    В Red Hat Linux установка пакета Shadow Password Suite, ответственного за теневые пароли, проста. Наберите как root:

    С теневыми (shadow) паролями файл « /etc/passwd » хранит сведения о пользователях в виде:

    Каждое поле в записи отделено символом “:”:

    Username, до 8 символов. Регистр важен, обычно пишут в нижнем регистре.

    Символ “x” в поле пароля. Пароли хранятся в файле « /etc/shadow ».

    Числовой user id. Назначается скриптом « adduser ». Unix использует данное значение и значение группы для определения кому какие файлы принадлежат.

    Числовой group id. Red Hat использует group id в довольно неожиданном способе усиления защиты файла. Часто group id равен user id.

    Полное имя пользователя. Максимальная длина мне неизвестна, но лучше ограничиться разумными рамками (до 30 символов).

    Домашний каталог пользователя. Обычно /home/username (например, /home/smithj). Там хранятся все личные файлы пользователя и его web-страницы.

    Пользовательская оболочка. Обычно используется « /bin/bash » для доступа к оболочке bash.

    Если нужно чтобы пользователь не имел доступа к shell, создайте скрипт « /bin/sorrysh », который выведет соотвтетствующее сообщение и завершит работу пользователя. Впишите скрипт сюда в качестве оболочки.

    Замечание: Если пользователь должен передавать файлы по “FTP” shell должна быть нормальной оболочкой, например, « /bin/bash », а чтобы не давать shell-доступа надо настроить доступ в домашнем каталоге пользователя. См. раздел Администрирование Web-сервера и HTTP Proxy в главе 7.

    Файл « /etc/shadow » хранит данные о пользователе в формате:

    Как и в файле passwd, каждое поле в файле shadow отделяется двоеточием:

    Username, до 8 символов. Совпадает с username в файле /etc/passwd.

    Пароль, 13 символов (зашифрованный). Пустая запись (то есть, ::) показывает, что для входа пароль не нужен (обычно идея плохая), и запись «*» (то есть, :*:) показывает, что вход заблокирован.

    Количество дней (с 1 января 1970), когда пароль был сменен в последний раз.

    Число дней до смены пароля (0 показывает, что он может быть сменен всегда).

    Число дней, после которых пароль должен быть сменен (99999 показывает, что пользователь может не менять пароль фактически никогда).

    Число дней, в течение которых пользователь получает предупреждения о необходимости пароль сменить (7 для полной недели).

    Число дней после окончания действия пароля, когда еще можно работать. Если пароль не сменить, после данного срока он выдохнется, и аккаунт будет заблокирован.

    Число дней, начиная с 1 января 1970, после которых пароль будет заблокирован.

    Зарезервировано для возможного будущего использования.

    Источник

    Linux no shadow file

    Traditional Unix systems keep user account information, including one-way encrypted passwords, in a text file called « /etc/passwd ». As this file is used by many tools (such as «ls») to display file ownerships, etc. by matching user id #’s with the user’s names, the file needs to be world-readable. Consequentally, this can be somewhat of a security risk.

    Another method of storing account information, one that I always use, is with the shadow password format. As with the traditional method, this method stores account information in the /etc/passwd file in a compatible format. However, the password is stored as a single «x» character (ie. not actually stored in this file). A second file, called « /etc/shadow », contains encrypted password as well as other information such as account or password expiration values, etc. The /etc/shadow file is readable only by the root account and is therefore less of a security risk.

    While some other Linux distributions forces you to install the Shadow Password Suite in order to use the shadow format, Red Hat makes it simple. To switch between the two formats, type (as root):

    /usr/sbin/pwconv To convert to the shadow format /usr/sbin/pwunconv To convert back to the traditional format

    With shadow passwords, the « /etc/passwd » file contains account information, and looks like this:

    Each field in a passwd entry is separated with «:» colon characters, and are as follows:

    Username, up to 8 characters. Case-sensitive, usually all lowercase

    An «x» in the password field. Passwords are stored in the « /etc/shadow » file.

    Numeric user id. This is assigned by the « adduser » script. Unix uses this field, plus the following group field, to identify which files belong to the user.

    Numeric group id. Red Hat uses group id’s in a fairly unique manner for enhanced file security. Usually the group id will match the user id.

    Full name of user. I’m not sure what the maximum length for this field is, but try to keep it reasonable (under 30 characters).

    User’s home directory. Usually /home/username (eg. /home/smithj). All user’s personal files, web pages, mail forwarding, etc. will be stored here.

    User’s «shell account» . Often set to « /bin/bash » to provide access to the bash shell (my personal favorite shell).

    Perhaps you do not wish to provide shell accounts for your users. You could create a script file called « /bin/sorrysh », for example, that would display some kind of error message and log the user off, and then set this script as their default shell.

    Note: Note: If the account needs to provide «FTP» transfers to update web pages, etc. then the shell account will need to be set to « /bin/bash » — and then special permissions will need to be set up in the user’s home directory to prevent shell logins. See Section 7.1 for details on this.

    The « /etc/shadow » file contains password and account expiration information for users, and looks like this:

    As with the passwd file, each field in the shadow file is also separated with «:» colon characters, and are as follows:

    Username, up to 8 characters. Case-sensitive, usually all lowercase. A direct match to the username in the /etc/passwd file.

    Password, 13 character encrypted. A blank entry (eg. ::) indicates a password is not required to log in (usually a bad idea), and a «*» entry (eg. :*:) indicates the account has been disabled.

    The number of days (since January 1, 1970) since the password was last changed.

    The number of days before password may be changed (0 indicates it may be changed at any time)

    The number of days after which password must be changed (99999 indicates user can keep his or her password unchanged for many, many years)

    The number of days to warn user of an expiring password (7 for a full week)

    The number of days after password expires that account is disabled

    The number of days since January 1, 1970 that an account has been disabled

    Источник

    Linux Shadow file explained in detail

    surendra : $6$1aEszVo.gsdPEr : 15107 : 22 : 99999 : 207 : 205 : 105345 :
    1 2 3 4 5 6 7 8 9

    1) User login name: This field gives details for user-login

    2) Encrypted password: The password is in encryption form8) No of days from Jan 1, 1970 the account was disabled: and it’s MD5 encrypted form. This field may contain following things

    • !! or ! indicates account is present but there is no password set for it. So user can not login if second field set to this values
    • :*: indicates the account was disable.
    • :: indicates that user can login without password. in other words we can say password removed
    • $6$b93VXzq0$kI55QxFMpXv This example encrypted form indicates password is present and encrypted.

    3) Last password change: Indicates when was the last time the password changed?. This is the number of days from 1st Jan 1970. To get this number to convert to human readable format please have a look in to our other post how to convert this number.

    4) Minimum days need for a password change: This is to make user to change the password only after some days. Suppose if this value is “0”, he can change the password at any time. If this value is 15, then the user can change the password only after 15 days. What will happen if he tried to change the password today it self tho this value set to 15?

    We will get following error

    5) Maximum days the password is valid: This is the days after which the password should change. If the value is 99999 then you no need to change the password, if this value is set to some 45 then you have to change the password after 45 days completion.

    6) Password expiry advanced warning days: This value is to warn the user that his password is going to expire in so and so days.. For example if this value is set to 10 days, then system will prompt to the user at every login that his password will expire in 10 days.

    7) No of days after password expired, account was disabled: This is to block unwanted access to an account once it’s password was expired.

    8) No of days from Jan 1, 1970 the account was disabled: This is to show when the account was disabled. Do you want to find all the accounts which were disabled? Click here

    9) Reserved for future purpose:Not used

    Some FAQ’s:

    How can I get encrypted password in /etc/passwd back from /etc/shadow file?

    use pwunconv command to revert back your encrypted passwords stored in shadow file.

    Why we need shadow file?

    As /etc/passwd file is world readable and can seen by any one. This is security loophole, so Linux machines moved encrypted password from /etc/passwd to /etc/shadow file. So even encrypted password is not seen by any normal user expect superuser(root).

    Источник

    Читайте также:  Windows server 2012 r2 dpc watchdog violation windows
    Оцените статью