Sam's Tech Blog

'You can check out any time you like, But you can never leave!'

2019-08-23

Change root password remotely

How to Change root password remotely using terminal

Change root password remotely

You can use this Bash script to change all root passwords in all servers on 10.200.100.0/24 network.

#!/bin/bash

# Script for remote changing root password for a bunch of servers

for ((i=1;i<=254;i++)); do \

ssh -t root@10.200.100.$i "echo 'root:NewPassWord' | chpasswd"; \

done;