ssh to two servers

Posted on 2009-12-22
Last Modified: 2013-11-08
I have setup keys between three Centos 5.2 servers.  One server will copy to lweb1 and lweb2.

The following individual commands work.
[username@lqa ~]$ scp test.txt username@lweb1:/home/username/
[username@lqa ~]$ scp test.txt username@lweb2:/home/username/

scp help looks like it can copy to two servers at the same time (user@host1, user@host2)
[username@lqa ~]$ scp
usage: scp [-1246BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]
           [-l limit] [-o ssh_option] [-P port] [-S program]
           [[user@]host1:]file1 [...] [[user@]host2:]file2

This is what happens when I try to copy to two servers at the same time.  

[username@lqa ~]$ scp test.txt username@lweb1:/home/username/ username@lweb2:/home/username/              
          deploynotes.txt                                                                     100%   35     0.0KB/s   00:00
username@lweb2's password:
/home/username: not a regular file
Killed by signal 1.
Connection to lweb1 closed.

Can I not copy to two servers at the same time in scp?
Question by:magnusthorne
    1 Comment
    LVL 57

    Accepted Solution

    No SCP can't copy to two hosts at once the host1 and host2 options allow you to copy a file from remote host1 to remote host2.


    Example to copy the file "foobar.txt" from remote host "" to remote host ""


    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    In order for businesses to be compliant with certain information security laws in some countries, you need to be able to prove that a user (which user it was becomes important to the business to take action against the user after an event has occurr…
    Creating a Samba server for a small office. Ubuntu Linux and Samba can breathe new life into a retired PC and save an office money on new hardware/software. Our example server will have two hard disks, one exclusively for storing shared data. …
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    745 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

    18 Experts available now in Live!

    Get 1:1 Help Now