Linux switch user password

Как изменить пароль пользователя в Linux. Команда Passwd

How to Change User Password in Linux

В этом руководстве мы объясним, как изменить пароль пользователя в Linux. Мы также покажем вам, как заставить пользователей изменить свой пароль при следующем входе в систему.

Инструкции должны работать на любом дистрибутиве Linux, включая Ubuntu, Debian и CentOS.

В Linux вы можете изменить пароль учетной записи пользователя с помощью passwd утилиты.

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

Как обычный пользователь, вы можете изменить только свой собственный пароль. Пользователь root и пользователи с привилегиями sudo могут изменять пароли других пользователей и определять, как можно использовать или изменять пароль.

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

Надежный пароль — это самое важное, что вы можете сделать для защиты своей учетной записи. Часто надежный пароль содержит не менее 16 символов и содержит как минимум одну заглавную букву, одну строчную букву, одну цифру и один специальный символ.

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

Изменить свой пароль пользователя

Чтобы изменить пароль своей учетной записи, введите passwd команду без аргументов:

Вам будет предложено ввести текущий пароль. Если пароль правильный, команда попросит вас ввести и подтвердить новый пароль.

Пароли не отображаются на экране при их вводе.

При следующем входе в систему используйте новый пароль.

Изменить пароль другого пользователя

Как мы упоминали во введении, только пользователь root и пользователи, имеющие sudo доступ, могут изменять пароль другой учетной записи.

В следующем примере предполагается, что вы вошли в систему как пользователь с привилегиями sudo.

Чтобы изменить пароль другой учетной записи пользователя, введите passwd команду, а затем имя пользователя. Например, чтобы изменить пароль пользователя с именем baks , выполните следующую команду:

Вам будет предложено ввести и подтвердить новый пароль:

В случае успеха команда напечатает что-то вроде этого:

Принудительно изменить пароль при следующем входе в систему

По умолчанию пароли никогда не истекают. Чтобы заставить пользователя изменить свой пароль при следующем входе в систему, используйте passwd команду с —expire параметром, за которой следует имя пользователя:

Приведенная выше команда немедленно истечет пароль пользователя.

В следующий раз, когда пользователь попытается войти со старым паролем, ему будет показано сообщение, заставляющее его сменить пароль:

Читайте также:  Пропало окно ввода пароля windows

Как только пользователь установит новый пароль, соединение будет закрыто.

Вывод

В этом уроке вы узнали, как изменить пароли пользователя и как установить срок действия пароля.

Вы можете найти больше информации о команде passwd, набрав man passwd в своем терминале или посетив страницу руководства Linux passwd .

Источник

How to Switch (su) to Another User Account without Password

In this guide, we will show how to switch to another or a specific user account without requiring a password. For example, we have a user account called postgres (the default PostgreSQL superuser system account), we want every user (typically our PostgreSQL database and system administrators) in the group called postgres to switch to the postgres account using the su command without entering a password.

By default, only the root user can switch to another user account without entering a password. Any other user will be prompted to enter the password of the user account they are switching to (or if they are using the sudo command, they will be prompted to enter their password), if they don’t provide the correct password, they get an “authentication failed” error as shown in the following screenshot.

User Authentication Failure Error

You can use any of the two solutions provided below to solve the above issue.

1. Using PAM Authentication Module

PAM (Pluggable authentication modules) are at the core of user authentication on modern Linux operating systems. To allow users in a specific group to switch to another user account without a password, we can modify the default PAM settings for the su command in the /etc/pam.d/su file.

Add the following configurations after “auth sufficient pam_rootok.so” as shown in the following screenshot.

In the above configuration, the first line checks if the target user is postgres, if it is, the service checks the current user, otherwise, the default=1 line is skipped and the normal authentication steps are executed.

The line that follows checks if the current user is in the group postgres, if yes , the authentication process is considered successful and returns sufficient as a result. Otherwise, the normal authentication steps are executed.

Configure PAM to Allow Running Su Command without Password

Save the file and close it.

Next, add the user (for example aaronk) that you want to su to the account postgres without a password to the group postgres using usermod command.

Now try to su to the postgres account as the user aaronk, you should not be prompted for a password as shown in the following screenshot:

Add User to Group

2. Using Sudoers File

You can also su to another user without requiring a password by making some changes in the sudoers file. In this case, the user (for example aaronk) who will switch to another user account (for example postgres) should be in the sudoers file or in the sudo group to be able to invoke the sudo command.

Then add the following configuration below the line “%sudo ALL=(ALL:ALL) ALL” as shown in the following screenshot.

Читайте также:  Как запустить google chrome linux

Add User to Sudoers File

Save and close the file.

Now try to su to the account postgres as the user aaronk, the shell should not prompt you to enter a password:

Switch to Other User Without Password

That’s all for now! For more information, see the PAM manual entry page (man pam.conf) and that of sudo command as well (man sudo).

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

We are thankful for your never ending support.

Источник

How do I change a user password in Ubuntu Linux?

W e recently switched from Windows server operating system to Ubuntu Linux operating system at work. I am a developer by profession and do not know much about Linux. I need to change the sftp/ssh user account password on Ubuntu. How do I change a user password in Ubuntu Linux?

Introduction – Your Ubuntu Linux account information stored in a file named /etc/passwd and encrypted password in /etc/shadow . This page explains to you how to change the Ubuntu Linux root and user account password using the passwd command line.

Tutorial details
Difficulty level Easy
Root privileges Yes
Requirements Ubuntu Linux
Est. reading time 2 minutes

How to change a user password in Ubuntu

  1. Open the terminal application by pressing Ctrl + Alt + T
  2. To change a password for user named tom in Ubuntu, type:
    sudo passwd tom
  3. To change a password for root user on Ubuntu Linux, run:
    sudo passwd root
  4. And to change your own password for Ubuntu, execute:
    passwd

How to change a root (superuser) password in Ubuntu

Firstly, open a terminal window. If you want to change the password for remote Ubuntu server, log in using the ssh command:
ssh user@ubuntu-server-ip
ssh vivek@ubuntu-webserver-1
Type ‘sudo -i’ at the command prompt, and Enter key:
sudo -i
Type the current user password and press Enter key. Finally type NA command and press Enter to change password for root user:
passwd

Change password for root user on Ubuntu

How do I change the user account password on Ubuntu?

Again open a terminal window. Type the following command to change the password for regular Ubuntu user account named jerry:
sudo passwd < userNameHere >
sudo passwd jerry ## ##
sudo passwd vivek ## ##

How to change the user Password in Ubuntu Linux

Deleting a user password

Users will not be able to log in when the password is deleted or expired on Ubuntu Linux.

  • No ads and tracking
  • In-depth guides for developers and sysadmins at Opensourceflare✨
  • Join my Patreon to support independent content creators and start reading latest guides:
    • How to set up Redis sentinel cluster on Ubuntu or Debian Linux
    • How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
    • How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
    • A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
    • How to protect Linux against rogue USB devices using USBGuard

Join Patreon

The syntax is as follow to remove the password for the account called tom:
sudo passwd -d tom
## OR ##
sudo passwd —delete jerry
You will see confirmation on screen as follows:

To set up a new password when deleted, run:
sudo passwd -d tom
We can also force expire the password for the named account jerry. Open the terminal and then type the following command:
sudo passwd -e jerry
sudo passwd —expire jerry
When user login they will be forced to reset their credentials when you use the -e / —expire option:

Linux locking an account

sudo passwd -l
sudo passwd -l tom

Linux unlocking an account

sudo passwd -u
sudo passwd -u tom

Conclusion

This quick tutorial taught you how to change the Ubuntu Linux root user and other user account password using the passwd command. You must root user to change the password for all other users, however users can change their password without sudo access. For more info see the passwd command help page using the man command man passwd

🐧 Get the latest tutorials on Linux, Open Source & DevOps via

Category List of Unix and Linux commands
Documentation help • mandb • man • pinfo
Disk space analyzers df • duf • ncdu • pydf
File Management cat • cp • less • mkdir • more • tree
Firewall Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04
Linux Desktop Apps Skype • Spotify • VLC 3
Modern utilities bat • exa
Network Utilities NetHogs • dig • host • ip • nmap
OpenVPN CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04
Package Manager apk • apt
Processes Management bg • chroot • cron • disown • fg • glances • gtop • jobs • killall • kill • pidof • pstree • pwdx • time • vtop
Searching ag • grep • whereis • which
Shell builtins compgen • echo • printf
Text processing cut • rev
User Information groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w
WireGuard VPN Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04

Comments on this entry are closed.

For your own password:
passwd
For root password:
sudo passwd root

FYI, we don’t set root password on Ubuntu for security reasons. One user will be added to the ‘sudo’ group and that will act as admin user. This ensures safety as root account without password is locked and cannot be used for ssh.

Источник

Читайте также:  Отключение административных общих ресурсов windows 10
Оцените статью