14

I have been using this server for a few months. At the beginning I sent the admin my public ssh key, and he set up the account for me, and I have only used the ssh key to log in. I definitely didn't have a password at first.

Since then I may or may not have set up a password using passwd. Right now if I use passwd I see this.

$ passwd
Changing password for user myusername.
Changing password for myusername.
(current) UNIX password:

While it seems to suggest that I do have a password, I have no memory of ever doing this.

How can I tell conclusively whether my password is set?

EDIT:
I can't log in nor change password, because I don't know what the password is (blank password doesn't work). The distro is Fedora release 20 (Heisenbug).

  • Try to log in without password (and without your ssh private key of course). – didierc Feb 15 '15 at 16:24
  • I can't log in because I don't know the password, and blank doesn't work. I added this info in the original question. – ceiling cat Feb 15 '15 at 16:46
  • On a login console, a blank password is the same as no password. – didierc Feb 15 '15 at 16:59
  • You'll get this password prompt even if there's no password configured for the account. If no password is configured, passwd will complain of a wrong password no matter what you type. – Gilles Feb 15 '15 at 22:27
  • I've verified that on a vanilla Fedora 20 using local shadow passwords, passwd will not ask for your current password if you do not have one. Another way to check is to type su myusername; if there's no password, it will not ask for one. But any of this can be overridden by the system administrator, for example by removing the nullok option from the pam_unix entries in /etc/pam.d/*, in which case a non-administrator cannot tell who has passwords and who does not, except perhaps by doing timing tests. – Mark Plotnick Feb 16 '15 at 16:13
24

The best way is with the following command:

passwd --status username

From man passwd:

Display account status information. The status information consists of 7 fields. The first field is the user's login name. The second field indicates if the user account has a locked password (L), has no password (NP), or has a usable password (P). The third field gives the date of the last password change. The next four fields are the minimum age, maximum age, warning period, and inactivity period for the password. These ages are expressed in days.

So, if the second output field is NP, then, that user has no password set.

  • I got $ passwd --status Only root can do that. – ceiling cat Feb 15 '15 at 16:43
  • In this case, try sudo passwd username --status. – jherran Feb 15 '15 at 16:45
  • I got $ sudo passwd myusername --status [sudo] password for myusername: but since I don't know my password, I can't continue. – ceiling cat Feb 15 '15 at 16:48
  • I tested my original command and should work fine with a newly created user without special perms: $ passwd --status test returns test P 02/15/2015 0 99999 7 -1. – jherran Feb 15 '15 at 17:09
  • Weird. I am wondering if the admin has set it up in a non-standard way. – ceiling cat Feb 15 '15 at 17:21
4

You can test this in 2 easy ways.

  1. Right after you change the password, as root type login, that will bring you to a login/password prompt.

  2. Depending on your system odds are you are using shadow passwords. The file for that is in /etc/shawdow you can look in that file to see if your account has any changes to it.

Here is an example with an account without a passwrod set:

postgres: :16462:0:99999:7:::

Here is what it might look like for a user with a password:

dustin:$6$TQ8e8o92$T9KWfcEVeIpDytW/zSAZzM4512wd/DiiuaYwrYWheH3LYpOsISdRxrCLvPqJZZ66QqdetmaV0ALQohx8nQPFKK0:16425:0:99999:7:::

Notice between the : : is the encrypted password and for the postgres account it had nothing

  • For #1, I can't change password, because I don't know what the password is. If I put in a blank, it says passwd: Authentication token manipulation error. For #2, I don't have /etc/shawdow. There is a /etc/shadow, but the permission is 000. (not sure if this matters) I forgot to mention that I have Fedora release 20 (Heisenbug). Probably should have put these information in the original question. – ceiling cat Feb 15 '15 at 16:38
  • Your token error tends to come from wrong permissions. Are you in Single usermode ? When you booted was it a normal boot? Also to check type just "mount" you want to make sure every thing is mounted as rw (read and write) – Dustin Hargrove Feb 15 '15 at 17:11
  • Also that is a wrong permission, what distro is this? – Dustin Hargrove Feb 15 '15 at 17:13
  • I don't think the server is in single user mode. I can still log in using ssh credentials, and I can see other users with who. Everything listed in mount is listed as rw. Distro is Fedora release 20 (Heisenbug). – ceiling cat Feb 15 '15 at 17:35
1

Try using the following:

passwd -S

From passwd(1) man page we read:

-S Report password status on the named account. The first part indicates if the user account is locked (LK), has no password (NP), or has an existing or locked password (PS). The second part gives the date of the last password change. The next parts are the minimum age, maximum age, warning period, and inactivity period for the password.

0

You may want to see the /etc/passwd file. The second field on your user indicates the password. If nothing is there you may have no password for your login. On the other hand, if you have an x on this field you have a password associated to it and it may be at the /etc/shadow file

  • Thanks! There is an x. I guess I do have a password. There is no /etc/shadow file though. – ceiling cat Feb 15 '15 at 16:45
  • 1
    @ceilingcat If you see an x, that doesn't tell you anything about whether a password is set. You need to look in /etc/shadow (which requires being root). – Gilles Feb 15 '15 at 22:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.