Solved

Starting a service remotely in Linux

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
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…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

929 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

12 Experts available now in Live!

Get 1:1 Help Now