?
Solved

Starting a service remotely in Linux

Posted on 2006-07-21
4
Medium Priority
?
232 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 40

Accepted Solution

by:
noci earned 1500 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

WordPress Tutorial 1: Installation & Setup

WordPress is a very popular option for running your web site and can be used to get your content online quickly for the world to see. This guide will walk you through installing the WordPress server software and the initial setup process.

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…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

764 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