How can I check a remote machines root password?
I have a remote machines that are normally accessed via ssh root and other users. For security purposes I have a script to change all keys and user passwords periodically from a central server.
For non root users the password is updated like so.
ssh -i a_priv_key root@ip "echo 'user:NEWPASS' | chpasswd"
And I check it has actually changed with this.
ssh -i b_priv_key user@ip "echo NEWPASS | sudo -S ls /root"
However if I want to do the same with the root user I am stuck. The sudo -S ls /root always returns a listing with any password because we just ssh'd in to the remote machine as root.
And if we ssh in as user sudo prompts for user's password.
I have been trying to get something with su user && su root because I noticed it will prompt for a root password but am not able to script it like the above.
'login root' from the root shell will also always prompt for a password but I cannot script the clear-text password to that either.
I have read this question but was hoping for a inbuilt method to do it rather than writing a custom application that must be installed on the remote machines. How to check password with Linux?