Solved

Starting a service remotely in Linux

Posted on 2006-07-21
4
227 Views
Last Modified: 2011-08-18
Hi Freinds

My question is that, is there any way we can start | stop | restart a service running in a  remote server using scripting.

The scenario is like this.

ServerA has a  service running, ServiceA.  I want to restart ServiceA through a script, provided I have full access to ServerA. I am not telling about remotely login into ServerA and restart the ServiceA. When ever I run the script from the remote server the ServiceA must be restarted. ServerA and the RemoteSystem is always connected through internet and have a static IP address.

I tried all the options of ssh. But I am not able to find a way, that is useble for the abouve purpose. Restarting a service remotely thorugh a script.

I needed this script very urgently. It would be very helpfull for me if you find a solution for my problem

Regards
0
Comment
Question by:dinkon4u
  • 2
4 Comments
 
LVL 39

Accepted Solution

by:
noci earned 500 total points
Comment Utility
ssh is perfect for this:

first generate a keypair, with or without passphrase is up to you, setup the public key in the authorization files account on serverA and the private key as identity file on serverB.
Files are depending the taste of SSH as does the syntax. (open ssh or others) for openssh (authorized_keys & authorized_keys2   +  identification)

then it should be sufficient to do:

ssh accountA@serverA /etc/init.d/serviceA restart

HIH
0
 
LVL 6

Author Comment

by:dinkon4u
Comment Utility
Hi HIH

Thanks for your prompt reply, I tried your options. It worked perfectly. Now would you please tell me How much secure is the connection.  .  . :) .

Regards

NB.
I encourgae others also to post other ways to run a service remotely.  If no one appears with a better solution than this, I have to give 500 points to HIH . . . :). I will kept this open for another 48HRS.
0
 
LVL 22

Expert Comment

by:pjedmond
Comment Utility
ssh is more secure than the user!!

Basically as long as any exploits are 'patched' (i.e. the ssh binaries are up to date), and the passwords/keys are correctly secured, then the ssh approach is more secure than most other mechanisms for remote connection. For genral FAQ on ssh, have a look here:

http://www.faqs.org/faqs/computer-security/ssh-faq/

(   (()
(`-' _\
 ''  ''
0
 
LVL 6

Author Comment

by:dinkon4u
Comment Utility
Thank you HIH for helping me.

Special thanks to pjedmond for telling about ssh ... :)
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

I have seen several blogs and forum entries elsewhere state that because NTFS volumes do not support linux ownership or permissions, they cannot be used for anonymous ftp upload through the vsftpd program.   IT can be done and here's how to get i…
Note: for this to work properly you need to use a Cross-Over network cable. 1. Connect both servers S1 and S2 on the second network slots respectively. Note that you can use the 1st slots but usually these would be occupied by the Service Provide…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now