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??
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.
username@host $ su - Password: [enter root's password] root@host # passwd username
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.
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