Search This Blog

2014-06-10

Automate Root Password Updates Linux and FreeBSD

In order to change root passwords via ssh you can login either as a user or using ssh keys and running a password change command that does not require user input

The commands that do not require user input for root password are:

FreeBSD
ssh -i .ssh/key -l root 'echo "newpassword" | pw usermod root -h 0'

Linux
ssh -i .ssh/key -l root 'echo "newpassword" | passwd root --stdin'

Remember to remove history when complete:
history -d (line_number)

References:
https://forums.freebsd.org/viewtopic.php?&t=4448
http://stackoverflow.com/questions/18571829/changing-a-password-with-one-command-in-freebsd/20104971#20104971

No comments:

Post a Comment