[SOLVED] Script that turns off a list of servers in network
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
You would generate single key pair without passphrase using command ssh-keygen from where you would execute your script.
Place Public key to all of the servers. Keep private key onto the system from where you would execute script using cronjob
How the script is going to be?
You would write the script from where you would execute the command.
Bring all the servers(ips)in loop or array.
Login on to server one by one using ssh command by using private key
and execute shutdown command then exit
Thanks All for all the important pointers.Its true,all one needs is pointer and I am on my way.I will definitely share this script ones its done.Maybe we can further enrich this one once we are through.
I tried this one but what it does is asks me for an input once it logins to the switch the output is
The authenticity of host '135.27.153.243 (135.27.153.243)' can't be established.
RSA key fingerprint is c1:99:8c:2e:37:42:e5:0f:02:84:47:85:e2:1c:cd:29.
Are you sure you want to continue connecting (yes/no)?
And now I have to enter is yes
But I dont want to input anything I want my script to do this.
But it only asks that once for a new machine, then it memorizes it for future ref. Its a security feature, see man-in-the-middle attack.
yeah you are right.It asks only once.Now my problem is I have to change the user to root to run the shutdown command on the list of servers.I think I will have to use expect for this purpose.
The error I receive is
Sorry, user init is not allowed to execute '/sbin/shutdown -h now' as root on S.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.