LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-14-2009, 05:16 AM   #16
abs_77
LQ Newbie
 
Registered: Feb 2007
Location: India, Bombay
Distribution: Linux & BSD
Posts: 23

Rep: Reputation: 15

One more workaround you can do using SSH

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

For more detail check ssh manual at (http://www.openssh.org)
another bash tutorial(http://www.linuxconfig.org/Bash_scripting_Tutorial)

Ofcourse, You would be shown the way to reach destination
but no one would lead you there.

ABS
 
Old 05-14-2009, 09:21 AM   #17
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
um, would:
Code:
ssh user@server sudo /sbin/shutdown -h now
not work ?
 
Old 05-14-2009, 09:31 AM   #18
Ajit Gunge
Member
 
Registered: Jan 2008
Location: Pune
Distribution: RHEL,fedora
Posts: 253

Original Poster
Blog Entries: 1

Rep: Reputation: 21
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.

Thanks
Ajit
 
Old 05-14-2009, 09:47 AM   #19
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by schneidz View Post
um, would:
Code:
ssh user@server sudo /sbin/shutdown -h now
not work ?
The OP hasn't stated he tried it this way.
 
Old 05-14-2009, 10:30 AM   #20
Ajit Gunge
Member
 
Registered: Jan 2008
Location: Pune
Distribution: RHEL,fedora
Posts: 253

Original Poster
Blog Entries: 1

Rep: Reputation: 21
Quote:
Originally Posted by Sergei Steshenko View Post
The OP hasn't stated he tried it this way.
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.

Ajit
 
Old 05-14-2009, 11:10 PM   #21
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,360

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
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.
 
Old 05-15-2009, 01:28 AM   #22
Ajit Gunge
Member
 
Registered: Jan 2008
Location: Pune
Distribution: RHEL,fedora
Posts: 253

Original Poster
Blog Entries: 1

Rep: Reputation: 21
Script still failing.....

Quote:
Originally Posted by chrism01 View Post
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.

Thanks,
Ajit
 
Old 05-15-2009, 01:36 AM   #23
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,360

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Add init to sudoers file and give him ability to run that cmd.
 
Old 05-15-2009, 02:22 AM   #24
Ajit Gunge
Member
 
Registered: Jan 2008
Location: Pune
Distribution: RHEL,fedora
Posts: 253

Original Poster
Blog Entries: 1

Rep: Reputation: 21
Quote:
Originally Posted by chrism01 View Post
Add init to sudoers file and give him ability to run that cmd.
Hmmmm...I will try to explain what I did and than you can tell me what I did wrong.

I added this entry in the sudoers file
vi /etc/sudoers.

init ALL=/sbin/shutdown.

And I run my script but it still gives me the same error.
Obviously I did something wrong but what is it?

Ajit
 
Old 05-15-2009, 09:06 AM   #25
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
this works in fedora:
http://www.linuxquestions.org/questi...1/#post3441308

is init some sort of special system user that has to do with the init command ?
 
Old 05-15-2009, 09:38 AM   #26
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by Ajit Gunge View Post
Hmmmm...I will try to explain what I did and than you can tell me what I did wrong.

I added this entry in the sudoers file
vi /etc/sudoers.

init ALL=/sbin/shutdown.

And I run my script but it still gives me the same error.
Obviously I did something wrong but what is it?

Ajit
Do you want anybody on the network to be able to shut down any server whenever he/she wants ?

Last edited by Sergei Steshenko; 05-15-2009 at 10:01 AM.
 
Old 05-15-2009, 09:40 AM   #27
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by Ajit Gunge View Post
Hmmmm...I will try to explain what I did and than you can tell me what I did wrong.

I added this entry in the sudoers file
vi /etc/sudoers.

init ALL=/sbin/shutdown.

And I run my script but it still gives me the same error.
Obviously I did something wrong but what is it?

Ajit
Please stop waisting our time.
  1. publish thew script source (copy-paste);
  2. publish the exact command line (copy-paste);
  3. publish the script screen output (copy-paste).

Last edited by Sergei Steshenko; 05-15-2009 at 10:41 AM.
 
Old 05-15-2009, 09:47 AM   #28
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
Quote:
Originally Posted by Sergei Steshenko View Post
Do you want anybody on the network to be able to shout down any server whenever he/she wants ?
i tried shouting down my server but it just sits there blinking at me moronically.
 
Old 05-15-2009, 10:01 AM   #29
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by schneidz View Post
i tried shouting down my server but it just sits there blinking at me moronically.
Fixed.
 
Old 05-15-2009, 10:36 AM   #30
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
^ but now my previous post isnt funny anymore...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Cisco Turns Routers Into Linux Application Servers LXer Syndicated Linux News 0 04-10-2008 10:50 PM
RTCW: ET--I get nothing from the servers list Choey Linux - Games 4 11-09-2004 03:42 PM
ET doesn't list servers anymore GT_Onizuka Linux - Games 7 08-09-2004 02:09 PM
Enemy Territory - List of servers for dialup players? furfurdemon666 Linux - Games 1 05-17-2004 10:57 AM
How do add daemons/servers to auto-startup list? bjc Linux - Newbie 2 10-23-2000 04:28 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:14 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration