Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8966187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:58:19+00:00 2026-06-15T16:58:19+00:00

This seems to be a pretty popular question, and one that has about 1,000

  • 0

This seems to be a pretty popular question, and one that has about 1,000 different answers depending on what forum you look at. Unfortunately, none work for me.

I’m trying to write a bash shell script that SSHes into a list of servers and runs a simple stop <x> service command to shutdown application servers on each machine.

To do this manually:

ssh user@server01.ourdomain.tld
user@server01.ourdomain.tld's password: ourpassword
Last login: Fri Nov 30 14:37:51 2012 from <some-ip-addr>
server01:[user@machinename ~]# (now we are SSHed in)

So I ask: given a set name of servers (server01 through server25), how can I write a bash script to SSH into all of them and run service ourservice stop? This script should not require any human interaction once kicked off, and so should provide the SSH command with the appropriate password (ourpassword) to use. Furthermore, I need properly exit (or just close connections) after the script SSHes into each server so we don’t hang resources (open connections, etc.). Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T16:58:21+00:00Added an answer on June 15, 2026 at 4:58 pm

    Do this

    1. Make yourself a public/private keypair, using the ssh-keygen command
    2. Save your private key in all of your servers, inside the .ssh/authorized_keys folder

    Now you can connect to any server without typing a password, which is our first objective here.

    Now you can send commands to your servers using the following syntax:

    ssh username@serverid 'command'
    

    There’s a nice if short description of this at this page.

    So, you just concatenate your 25 commands in a file and fire that up, like this:

    ssh user@server1.yourservers.com 'service ourservice stop'
    ssh user@server2.yourservers.com 'service ourservice stop'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been pretty puzzled by this one. It seems as though my implementation of
This is something that has always bothered me about PHP and I have never
Has anyone managed to extend a GridView with default sorting? This seems pretty trivial
This seems pretty a straight-forward question, but I could not find a specific answer
This seems to be a pretty popular topic, but... I have the following XAML:
I am trying to get my head around this query - seems pretty straight
This seems like it should be pretty straight forward, but I'm apparently confused. I
Alright I don't see why this isnt working. It seems pretty simple. Here is
Getting friends of friend are pretty easy, I got this which seems to work
This feels like it should be pretty simple, but not much seems to be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.