Solved

Starting a service remotely in Linux

Posted on 2006-07-21
4
229 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 40

Accepted Solution

by:
noci earned 500 total points
ID: 17154124
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
ID: 17159631
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
ID: 17161219
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
ID: 17166268
Thank you HIH for helping me.

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

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

777 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