Once the user account is disabled, you will not be able to access the Linux system via SSH until the user account is activated. # usermod -U daygeek Method-3: Enable and Disable SSH access for user in LinuxĪlternatively, a user account can be locked by assigning the nologin shell to the given user. Run the usermod command with the -U switch to unlock the given user account. Run the usermod command with the -L switch to lock the given user account.ĭaygeek:!!$6$tGvVUhEY$PIkpI43HPaEoRrNJSRpM3H0YWOsqTqXCxtER6rak5PMaAoyQohrXNB0YoFCmAuh406n8XOvBBldvMy9trmIV00:18047:7:90:7::: It is primarily used to add a user to a specific group. The ‘usermod’ command is often used by Linux administrator’s to modify a given user account information. Passwd: Success Method-2: Locking & Unlocking user account with usermod command Run the passwd command with the -u switch to unlock the given user account. # grep daygeek /etc/shadowĭaygeek: !!$6$tGvVUhEY$PIkpI43HPaEoRrNJSRpM3H0YWOsqTqXCxtER6rak5PMaAoyQohrXNB0YoFCmAuh406n8XOvBBldvMy9trmIV00:18047:7:90:7::: If the account is already locked, two exclamation marks will be prefixed to the user password at ‘/etc/shadow’ file. In our example the output is LK meaning the password is locked. The above output will show few pieces of information about the status of the password for the given account. You can check the locked account status either by using passwd command or filter the given user name from ‘/etc/shadow’ file.Ĭhecking the user account locked status using passwd command. Run the passwd command with the -l switch, to lock the given user account. The passwd command is one of the frequently used command by Linux administrator’s to update user’s authentication tokens in the /etc/shadow file. Uid=2240(daygeek) gid=2243(daygeek) groups=2243(daygeek),2244(ladmin) Method-1: How to lock, unlock and check status of the user account using passwd command? Use the ‘id’ command to check if the given user is available in the system before locking or unlocking. Let’s use the “ daygeek” test user account to understand how this works: usermod:Used to modify/update (given) user’s account information & add a user to a specific group, etc.,.passwd:Used to update user’s authentication tokens & is achieved by calling the Linux-PAM and Libuser API.Let’s understand the three ways to perform password lock & unlock by employing these two commands: This tutorial will show you how to manually lock and unlock user accounts in Linux. However, manual unlock is needed for user accounts, if the lock period is set for longer duration. If a password policy is pre-implemented in your organization, then there is no need to verify this, as locked accounts will auto-unlock according to the configuration.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |