How to login to Ubuntu 18.04 without a password
I have just upgraded to Ubuntu 18.04 from 16.04 and I appear to have lost my ability to login without a password. This is something that I used in 16.04 for a media player computer that I have in my living room. This question appears to have been asked before, and has been marked as a duplicated here: How can I log in to Ubuntu 18.04 without a password? Setting auto login doesn’t work However, the answers are about auto-login and I do not want this. I want to get a login dialog with a user name that requires no password, not one that auto-logins in on boot. This is so that I can choose which account to login in to (I have one account for playing media and my own «real» account which I use for sys admin), or so that I can choose session types (my media account mostly uses kodi, but sometimes I need a desktop). This was possible with previous versions of Ubuntu: http://ubuntuhandbook.org/index.php/2013/07/login-without-a-password-on-ubuntu/ Has it been lost in 18.04?
2 Answers 2
I do exactly this myself, and upgraded the box from 16.04 to 18.04 a few weeks ago — with zero ill effects.
Run sudo passwd -d username to delete the password for this user.
That should allow you to login without entering a password, and works fine for me on 18.04
If this is your only account on the machine, you should probably either configure passwordless sudo, or add a second account with administrative privileges.
Yes, I guess this will be the way to go, although I was a bit wary of this because it will effect all authentication, including over a network. I guess the risk are relatively low for a media box, but still.
By default ssh disallows login with empty password, so it’s only accessible on the local console. You can verify that PermitEmptyPasswords is set to no in /etc/ssh/sshd_config .
Creating a user without a password
Nothing is wrong, the authentication failed as expected. You won’t get a «there is no password, you can’t login» error message.
Either create it as root and set the correct permissions, or execute su git as root where you don’t have to provide a password.
I just wanted to point out that letting the git user have Bash as a shell is a bad idea, security wise. That would allow users of this repo to get a shell in your server. If you set the shell to /usr/bin/git-shell you can limit their account to using git and nothing else. (You should also limit SFTP access but that can only be done from /etc/sshd_config). Now, once you changed the shell, «su» won’t work as-is. You’ll have to do «su -s /bin/sh git» instead.
7 Answers 7
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.
You’ve created a user with a “disabled password”, meaning that there is no password that will let you log in as this user. 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:
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 ).
Ubuntu 19.10 seems like does not have —disabled-password parameter, could there be any alternative solution
@alper Write the full path: sudo -u git cat /wherever/main.py . Or add a cd command: sudo -u git sh -c ‘cd /wherever && cat main.py’ . If you want to be sure that the other user doesn’t get access to the current directory even if the command doesn’t do what was intended, change directories outside: (cd /wherever && sudo -u git cat main.py)
@alper You didn’t use the commands I posted. You used one of many variants (too many for me to guess the exact one) that would result in this particular error. You need to invoke a shell for cd and && .
If you want to access the system under the git user you should use sudo:
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.
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.
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 terminal as mentioned in that answer, although I haven’t tried to do it myself.
Make No Password Required on local linux (tty) login
I want to allow a user that is logging in to the system locally (ie. keyboard & mouse) to not have to enter a password. Is this possible? I have the system locked down extremely well with SSH, and it sits with me always, so I it is not an issue.
@Sammitch, on an embedded development system (pre-release), that you are actively developing, where every time you boot, you want to save a few seconds not having to deal with the password of the user account, I think this is an absolutely fantastic idea that should deserve a gold medal. OPs question is helping me find a solution. I’m happy he asked so I don’t have to ask myself. I too find his reasoning somewhat naive.
5 Answers 5
This may be bad security but as noted if you have physical access to a non encrypted laptop you could get into the files and reset passwords with a linux live cd/usb or sometimes the grub menu lets you boot to recovery root and you can change the password.
Do you mean a virtual console or the default graphical console?
Login Settings (GNOME/KDE) should have option to boot to desktop without password.
Arch linux has a guide which I think should work for other systemd distros.
and put the following into the file
[Service] ExecStart= ExecStart=-/usr/bin/agetty --autologin username --noclear %I $TERM
I think that should let you autologin to the first console.
This doesn’t work for me. It says ‘root (automatic login)’ but then It still asks for password. Probably, something should be tuned in PAM configuration.
Following from the great information from @Roman I modified his answer somewhat for the solution on my system, which was Debian. For anyone else needing this; for Debian, edit /etc/systemd/system/getty.target.wants/getty\@tty1.service and add —autologin root to the line which begins with ExecStart=- so that it reads:
ExecStart=-/sbin/agetty --autologin root --noclear %I $TERM
Hope that helps. I realize it is a security risk in most cases. But when it is an embedded router that is strapped to the bottom of my desk and all external authentication is done with 2 factor authentication. I am not too worried.
Thank you for the help @Roman!