Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 18
Hi to all, I need to make an mass-ssh connection. I mean that; I have a text file that thousand IP addresses. I need to make ssh connection to this ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Feb 2008
    Posts
    13

    Mass ssh connection..


    Hi to all,
    I need to make an mass-ssh connection.
    I mean that;
    I have a text file that thousand IP addresses. I need to make ssh connection to this ip address one by one. I will create a text file each ssh server.

    Thanx for your help.

  2. #2
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,440
    For a one-time action pssh comes to mind.
    If you dont want to enter thousands of passwords, then you need
    an existing and working key authentication setup or an expect script.

    For regular tasks, I highly recommend to use a systemconfig tool such as puppet.
    You must always face the curtain with a bow.

  3. #3
    Just Joined!
    Join Date
    Feb 2008
    Posts
    13
    Thanx for your answer.

    My problem is not enter password. All servers have public key (Of course i have a master) I don't need to enter password for ssh connection for this servers.

    My problem is how to make a connection to this IP addresses. for example ssh root@44.33.33.22. I must use a text file to give IP 's to ssh command in a bash script. Like that This is stupid i know)
    ssh root@$SERVERS

    I think a shell script while should help me..

  4. $spacer_open
    $spacer_close
  5. #4
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,440
    Read the man page for pssh.
    I believe, -h switch is what you want.
    man page pssh section 1

    Code:
    man parallel-ssh
    Last edited by Irithori; 08-24-2012 at 11:37 AM. Reason: on debian, it is not pssh but parallel-ssh
    You must always face the curtain with a bow.

  6. #5
    Just Joined!
    Join Date
    Feb 2008
    Posts
    13
    Thanx again,
    Actually i must to make this using shell script or ssh. Because my company rules not allow install an another package.

    Is there any idea to do that using shell script?

  7. #6
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,440
    Of course one can implement a loop in bash.
    But you would need to code any needed feature yourself, hence it needs development and debugging time.

    pssh is a well known and tested python script with a lot of usefull features.
    It is available via the debian standard repository and you only need to install it on one machine (the one which connects to to the thousand machines)

    Code:
    cat /etc/debian_version 
    6.0.5
    apt-cache search pssh
    pssh - Parallel versions of SSH-based tools
    So if the choice is between installing one small tool via standard methods and start using it
    or reinventing the wheel by coding it in bash, then testing/debugging and only then start using it,
    I would for sure go for the first option.
    You must always face the curtain with a bow.

  8. #7
    Just Joined!
    Join Date
    Feb 2008
    Posts
    13
    you are right.
    pssh is simple way to do it.

    My scripting experience is not enough for write this kind of script.

    Is there any friend to hep me about this shell script?

  9. #8
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,440
    In order for anyone to help you,
    you might want to specify exactly what this script shall be capable of.

    From the top of my head:
    - Do you want parallel execution? Probably yes if there are a thousand machines. But then you need a way to set a limit on the parallel threads.
    - Is each of the connection independend from the others or are there dependencies?
    - What shall happen with stdout and stderr of each connection?
    - What happens for a timeout or connection refused?
    - That textfile, you want to create on the remote machines: Where, which permisions, which user, which content?
    - Is there a need to restart or signal a daemon after the file has been placed?
    There are for sure more points.

    It would also be good if you already start working on a script and then post it here, so that members can see where you want to go.
    You must always face the curtain with a bow.

  10. #9
    Just Joined!
    Join Date
    Feb 2008
    Posts
    13
    Hi again,
    Paralel connection is not must. I have too many time, operation can take a long time, it's not problem.
    I will give a time out to ssh, 10 seconds timeout is a reason to next host.
    Textfile contains hosts, i will not create it. It's already created.
    Host don't need to restart.

    I will start a command on ssh with a ssh parameter. For example; i 'll create a text file on remote host. It's not complex operation.

    I only need to know how to give ip address to ssh command from a text file using shell script.

    It's important for me.

    Thanx for your helps.

  11. #10
    Just Joined!
    Join Date
    Oct 2006
    Posts
    32
    Try mass.pl - very useful perl script.

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •