Unix & Linux: Creating a user without a password (5 Solutions!!)

preview_player
Показать описание
Unix & Linux: Creating a user without a password

The Question: I'm trying to create a user without password like this:
sudo adduser \
--system \
--shell /bin/bash \
--gecos 'User for managing of git version control' \
--group \
--disabled-password \
--home /home/git \
git
It's created fine. But when I try to login under the git user I'm getting the
password entering:
su git
Password:...
When I leave it empty I get an error:
su: Authentication failed
What's wrong?

Solutions: Please watch the whole video to see all solutions, in order of how many people found them helpful

== This solution helped 9 people ==
If you want to access the system under the git user you should use sudo:
sudo -s -u git
or
sudo su - git

== This solution helped 32 people ==
You've created a user with a "disabled password", meaning that there is no
password that will let you log in as this used. This is different from creating
a user that anyone can log in as without supplying a password, which is
achieved by specifying an empty password and is very rarely useful.
In order to execute commands as such "system" users who don't log in normally,
you need to hop via the root account:
su -c 'su git -c "git init"'
or
sudo -u git git init
If you want certain users to be able to run commands as the git user without
letting them run commands as root, set up sudo (run visudo as root and add a
line like %gitters ALL = (git) ALL).

== This solution helped 43 people ==
The --disabled-password option will not set a password, meaning no password is
legal, but login is still possible (for example with SSH RSA keys).
To create an user without a password, use passwd -d $username after the user is
created to make the password empty. Note not all systems allow users with empty
password to log in.

== This solution helped 6 people ==
Create an user with empty password
sudo useradd test-user-0
echo test-user-0:U6aMy0wojraho | sudo chpasswd -e
su test-user-0
The password prompt still shows unfortunately.
But if you just hit enter without typing anything, and it logins as the user
test-user-0.
The -e flags tells chpasswd that the password is already encrypted, and
U6aMy0wojraho is the hash of the empty string.
Tested on Ubuntu 18.04.
Terminal autologin with getty -a
On the terminal at least, you don't need to create an user without a password
to allow someone to not type their passwords every time.
I was able to do this on BusyBox by modifying inittab: https://
typing-the-root-username-or-password-in-build
So I believe that it should not be very hard to adapt that technique by
modifying Ubuntu 18.04's systemd init system scripts to setup a getty -a <user>
terminal as mentioned in that answer, although I haven't tried to do it myself.

Рекомендации по теме
visit shbcf.ru