bash - How can I change default root password on multi server -
how can change default root password (root's password provided via centos installation) on multi server after install new centos on servers.
i can use ansible tool complete issue it's not work first time root password.
how can achieve purpose.
updated: don't want login each server change password. want change root password remote server via ssh , can complete @ least effort.
solution:
use ansible + below command easiest way change root pass on multi server.
echo "newpass" | passwd root --stdin
you try automate using expect. have used expect in past auto log in routers perform actions. expect scripts bit macros. can install expect
sudo apt-get install expect
or
yum install expect
you create expect script , run each of 100 servers (possibly via shell script). example basic expect script give idea of does:
spawn ssh -l admin 123.111.123.11 match_max 100000 expect -ex "this system authorized use only.password:" send -- "topsecret\r" expect -ex "terminal type? \[xterm\]" send -- "\r" send -- "\n" expect -ex "myserver\[admin\]#" send -- "/usr/bin/uptime \r\n" expect -ex "myserve\[admin\]#"
obviously need change script should 'expect' actual output centos machines 'expected' stuff above router. link below more complicated script setting passwords might helpful you: http://surniaulula.com/2012/10/14/change-passwords-with-ssh-and-expect/
Comments
Post a Comment