Connect with us

Hi, what are you looking for?

Latest

How to Switch (su) to another passwordless user account

 

On this information, we are going to present the best way to swap to a different or a particular consumer account with out requiring a password. For instance, we now have a consumer account referred to as postgres (the default PostgreSQL superuser system account), we would like each consumer (usually our PostgreSQL database and system directors) within the group referred to as postgres to modify to the postgres account utilizing the su command with out getting into a password.

By default, solely the foundation consumer can swap to a different consumer account with out getting into a password. Another consumer will probably be prompted to enter the password of the consumer account they’re switching to (or if they’re utilizing the sudo command, they are going to be prompted to enter their password), in the event that they don’t present the proper password, they get an “authentication failed” error as proven within the following screenshot.

How to Switch (su) to another passwordless user accountPerson Authentication Failure Error

You need to use any of the 2 options offered under to resolve the above situation.

1. Utilizing PAM Authentication Module

PAM (Pluggable authentication modules) are on the core of consumer authentication on fashionable Linux working techniques. To permit customers in a particular group to modify to a different consumer account with out a password, we are able to modify the default PAM settings for the su command within the /and so forth/pam.d/su file.

# vim /and so forth/pam.d/su
OR
$ sudo vim /and so forth/pam.d/su

Add the next configurations after “auth enough pam_rootok.so” as proven within the following screenshot.

auth [success=ignore default=1] pam_succeed_if.so consumer = postgres
auth enough pam_succeed_if.so use_uid consumer ingroup postgres

Within the above configuration, the primary line checks if the goal consumer is postgres, whether it is, the service checks the present consumer, in any other case, the default=1 line is skipped and the traditional authentication steps are executed.

auth [success=ignore default=1] pam_succeed_if.so consumer = postgres

The road that follows checks if the present consumer is within the group postgres, if sure, the authentication course of is taken into account profitable and returns enough in consequence. In any other case, the traditional authentication steps are executed.

auth enough pam_succeed_if.so use_uid consumer ingroup postgres

How to Switch (su) to another passwordless user accountConfigure PAM to Permit Operating Su Command with out Password

Save the file and shut it.

Subsequent, add the consumer (for instance aaronk) that you simply wish to su to the account postgres with out a password to the group postgres utilizing usermod command.

$sudo usermod -aG postgres aaronk

Now attempt to su to the postgres account because the consumer aaronk, you shouldn’t be prompted for a password as proven within the following screenshot:

$ su – postgres

How to Switch (su) to another passwordless user accountAdd Person to Group

2. Utilizing Sudoers File

You can even su to a different consumer with out requiring a password by making some adjustments within the sudoers file. On this case, the consumer (for instance aaronk) who will swap to a different consumer account (for instance postgres) must be within the sudoers file or within the sudo group to have the ability to invoke the sudo command.

$ sudo visudo

Then add the next configuration under the road “%sudo ALL=(ALL:ALL) ALL” as proven within the following screenshot.

aaronk ALL=NOPASSWD: /bin/su – postgres

How to Switch (su) to another passwordless user accountAdd Person to Sudoers File

Save and shut the file.

Now attempt to su to the account postgres because the consumer aaronk, the shell mustn’t immediate you to enter a password:

$ sudo su – postgres

How to Switch (su) to another passwordless user accountSwap to Different Person With out Password

That’s all for now! For extra data, see the PAM guide entry web page (man pam.conf) and that of sudo command as effectively (man sudo).

$ man pam.conf
$ man sudo

If You Admire What We Do Right here On TecMint, You Ought to Contemplate:

TecMint is the quickest rising and most trusted neighborhood website for any type of Linux Articles, Guides and Books on the net. Tens of millions of individuals go to TecMint! to go looking or browse the 1000’s of revealed articles obtainable FREELY to all.

For those who like what you might be studying, please think about shopping for us a espresso ( or 2 ) as a token of appreciation.

How to Switch (su) to another passwordless user account

We’re grateful on your by no means ending help.

su root without password,su without password prompt,linux switch user with password,sudo as another user nopasswd,sudo as non root,linux allow user to sudo as another user,sudo switch user and execute command,sudo to non root user,sudo su user password,linux sudo command,unable to switch user in linux,sudo su permission,sudo as different user,su without a password,sudoers run command as another user,su no password entry for user,the command "su alice",how to use su command in shell script,su: permission denied,switch user with password in shell script,pass password to su command without a prompt,su command in linux with examples,sudo su command in shell script,su command with password,linux su -c option,sudo su command in linux,su to another user without password,allow user to su to another user,switch user in shell script without password,how to switch root user in linux without password,linux run command as another user without password,sudo su without password

You May Also Like

Hosting

Introduction In previous articles we have talked about images of dockers, the origin and functioning of dockers and the dockers’ hub. In this document...

Latest

Linux desktops are good in many ways, but like Windows they are not known as the most efficient battery. This does not mean that...

Latest

The United States Supreme Court has indicated that it will finally solve a problem that has been causing legal problems for almost two decades:...

Hosting

To secure your AWS assets, follow these AWS Identity and Access Management (IAM) guidelines. Locking the Root User Access Key for AWSAccount You use...