- How to Switch (su) to Another User Account without Password
- 1. Using PAM Authentication Module
- 2. Using Sudoers File
- If You Appreciate What We Do Here On TecMint, You Should Consider:
- Linux Mint Forums
- Login without password
- Login without password
- Re: Login without password
- Re: Login without password
- Re: Login without password
- Re: Login without password [SOLVED for me]
- Re: Login without password
- Re: Login without password
- Re: Login without password
- Re: Login without password
- How to create a user without password in Linux
- What is passwd command?
- What is useradd command?
- Method-1: Creating a user without password using passwd command
- Method-1.a: Using passwd comamnd
- Method-2: Creating a user without password using chpasswd command
- Method-3: Creating a user without password using useradd command
- Method-3.a: Using /sbin/nologin shell
- Method-3.b: Changing the shell to false
- Method-3.c: Changing the shell to /dev/null
- Closing Notes
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.
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.
Источник
Linux Mint Forums
Welcome to the Linux Mint forums!
Login without password
Login without password
Post by tcotariu » Sun Jun 30, 2013 11:57 am
Login without password
I am using Mint 14 Mate on one of my systems that I want to setup with an account that does not require a password.
I have done the following:
Control Center
Users and Groups
Add
Activated and tested the account
Control Center
Users and Groups
Highlight the account
Select “Change. ” for “Password”
Entered in the current account password
Checked the box for “Don’t ask for password on login”
Entered in the appropriate password to authenticate the change to the systems configuration
Tested the account
I am still prompted for a password.
This is not the only account on the systems, but it is the only one that I want to be able to login without a password.
Anybody know what I can do to get this to work?
Re: Login without password
Post by xenopeek » Sun Jun 30, 2013 12:08 pm
Re: Login without password
Post by tcotariu » Sun Jun 30, 2013 12:26 pm
xenopeek,
Thanks, that works.
The only “gotcha” here is that now in order to login to any account other than the one setup for automatic login, you have then «switch user» rather than entering in the name of the user you want to login as and then either entering in a password, or not if ine is not required for that account.
In my case, I think this is actually better for my purposes on this particular machine, it was just not what I had expected.
Oh, and thanks for the quick response!
Re: Login without password
Post by Reorx » Sun Jun 30, 2013 1:13 pm
Full time Linux Mint user since 2011 — Currently running mostly LM19C and a little LM20C.
Re: Login without password [SOLVED for me]
Post by newbie00000 » Sun Jul 06, 2014 4:20 am
I tried what xenopeek suggested, and indeed now there’s automatic logon of ‘guest’, so I need to log out (switch user) to log in as ‘myself’, just like tcotaria says, which is not ideal, but it’s OK.
But there’re 2 things I really really don’t like:
— At startup, now I only see a black screen, and the next screen is the Mint Desktop for ‘guest’. I lost the boot screen! I still have Windows XP on this PC, and I have no idea how to get Windows booted now. How can I get the boot screen back (as before, always at startup), or how can I get it if I need it?
— When I now choose System > Login Window, I don’t get the program I got before (as described by xenopeek). Instead, I get the Mint login screen! So I can’t change anything back. How can I change it back?
Thanks in advance!
Re: Login without password
Post by Mute Ant » Sun Jul 06, 2014 7:10 am
»How can I get the boot screen back»
Holding down the right-shift key while the machine is booting is supposed to display the GRUB multi-boot menu.
»System > Login Window, I don’t get the program I got before. instead, I get the Mint login screen»
That sounds like Xorg crashing.
You should look at this list http://www.linuxmint.com/oldreleases.php Mint14 will not be getting any more attention, eventually the Software Manager will stop working too.
Re: Login without password
Post by newbie00000 » Thu Jul 10, 2014 3:02 pm
Thank you for your answer!
Boot screen:
I got the boot screen back. Don’t know what did the trick, but this problem is solved
Settings > New login:
I’m not sure what you mean with Xorg crashing and the comment about Mint14. I guess you mean it’s a known problem for Mint14. But I’m using Mint13.
I’ll learn to live without a working ‘settings > new login’. I’ll never add any new user anymore. The automatic logon of ‘guest’ should be good enough for every other user of this pc (except for me). And since I’ve found that I can logout ‘guest’ using ALT-F4, enter (without mouse), I’m happy enough.
Re: Login without password
Post by Mute Ant » Thu Jul 10, 2014 4:38 pm
Re: Login without password
Post by newbie00000 » Sat Jul 12, 2014 9:00 am
Источник
How to create a user without password in Linux
This article title may sound awkward to you, but it’s useful. You may ask, why would we want to create a user without a password. I thought that too, but my friend faced this question in one of the interviews.
So, I want to share this with users who are looking for an answer to this question. Practically it may not be useful, but you should know the answer.
This article shows you how to create a user account without a password OR an empty password on Linux.
What is passwd command?
The passwd command is one of the most frequently used command by Linux administrator’s to update users’ authentication tokens in the /etc/shadow file by calling the Linux-PAM and Libuser API’s.
What is useradd command?
Linux is a multi-user operating system that allows more than one user to interact with the system at the same time. The “useradd” command is used to create new user accounts. When executed, “useradd” command creates a new user account as per the options specified in the ‘/etc/default/useradd file’ & ‘/etc/login.defs’ file.
Now let’s delve into some of the methods used to create a user account without password:
Method-1: Creating a user without password using passwd command
You can create a user without a password on Linux using the “passwd” command as follows :
Run the useradd command to create a user account as shown in the example below.
Note: we can use the commands “useradd” or “adduser” interchangeably to create a user in Linux.
useradd is native binary compiled with the system. But, adduser is a perl script which uses useradd binary in back-end. adduser is more user friendly and interactive than its back-end useradd. There’s no difference in features provided.
Once you have created the user, use the passwd command to remove the user’s password.
Details:
- -f or —force Force operation
- -u or —unlock Unlock the password for the named account (root only)
Method-1.a: Using passwd comamnd
Alternatively, you can use the -d option with the passwd command to remove the password for a user.
Details:
- -d or —delete Delete the password for the named account (root only)
Now, you’ve created a user with “disabled password”. But when you try to access it, it will ask for the password at the same time not allowing you to login.
You might get an error message saying “Access denied”.
That’s the expected behavior and you will not receive an error message such as “No password, you cannot login”.
Method-2: Creating a user without password using chpasswd command
You can create a user with an empty password on Linux using the “chpasswd” command.
Run the below command to create a user account:
Once you have created the user, use the below command to remove the user’s password. The -e option expects a hashed password, but you are given a simple password, which is why it is not taken.
Details:
- -e or —encrypted Supplied passwords are encrypted
Method-3: Creating a user without password using useradd command
You can create a password-free user on Linux using the “useradd” command.
The -p option expects a hashed password, but you are provided with a simple password, which is why it is not taken.
Details:
- -p or —password Encrypted password of the new account
Method-3.a: Using /sbin/nologin shell
User account can be created with the /sbin/ nologin shell option. This shell usually does not allow the user to log in to the computer.
You will receive the following message when you attempt to switch the account from the root.
Details:
- -s or —shell Login shell of the new account
Method-3.b: Changing the shell to false
We can use the /bin/false option with the “useradd” command to create a new user without password. ‘/bin/false’ is just a binary that immediately exits, returning false, when it’s called. The user logs in and immediately sees the login prompt again.
This shell works exactly like the one above, and it does not allow the user to log in to the computer.
When you try to switch the account from the root you get nothing.
Method-3.c: Changing the shell to /dev/null
‘/dev/null’ is a simple device which is implemented in software and doesn’t correspond to any hardware device on the system.
dev/null looks empty when you read from it, whereas data written to this device simply “disappears.”
User can be disabled by changing the shell to /dev/null as shown below:
Closing Notes
You learnt different ways to create a user without a password in Linux.
If you found this article helpful, please do share with your friends and spread the knowledge. Please feel free to comment below if you have any queries/concerns. We will get back to you as soon as we can. Happy learning!
Источник