0

I am logging into a server with my ssh key and user adm, I need to reset the password for the same user I am logging with but, when I type the passwd command it shows me a message that asks me for the actual password of the user, which I dont know. How can I remove that password policy where it requests you the actual password each time you want to reset??

  • 1
    If you have sudo access on the host, use sudo passwd adm. Of course, that would ask you for the same password unless sudo is configured not to require passwords. – Kusalananda Apr 20 '17 at 16:13
  • @Kusalananda Your comment should be an answer – Bruno9779 Apr 20 '17 at 16:15
  • 1
    @Bruno9779 You're free to take it and make it an answer. I'm blissfully unaware of the authentication machinery on Linux (PAM etc.), and knowing that I am, I'm leaving it as a comment until someone who knows more than I do can compose a complete and verified answer. – Kusalananda Apr 20 '17 at 16:19
  • 1
    @Bruno9779 as Kusalananda pointed out in his original comment, that would still require the OP to know the password. user3105533, that policy is there so that only someone who already has the right to log in as that user may change the password. You don't, so you really should be talking to the system's administrator. – terdon Apr 20 '17 at 16:24
  • Are you asking “How do I change my password, if I do not know my password?”? – ctrl-alt-delor Apr 20 '17 at 16:24
1

By design, Linux won't let you change your password without giving your original password. This is (in part) to keep you safe from yourself and from programs you run (i .e. a program that you run can't change your password without knowing your current password).

The superuser, root, is above such worldly concerns, however. So, if you have superuser access either directly (via su) or indirectly (via sudo), you can use those privileges to have the superuser reset your password, obviating the need to know what it currently is.

Directly:

username@host $ su - 
Password: [enter root's password]
root@host # passwd username

Indirectly:

username@host $ sudo passwd username
Password: [enter username's password]

Since you don't know your current password, you'll have to take the direct route.

0

The passwd command, when run as a normal user, will always ask for the current password before changing it. This is obviously a security feature, to prevent someone with physical access to your machine to lock you out of your account.

When run as root (or with sudo, same thing), passwd will allow you to change the password of any user without knowing it.

Another approach, that still requires sudo or access to the root account, is deleting the hashed password from /etc/shadow. This effectively replaces the password with an empty one

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.