답변:
방법이 있습니다. 이 Ubuntu 맨 페이지를 살펴보십시오 .
이름
parallel-scp - parallel versions of scp
개요
parallel-scp [OPTIONS] -h hosts.txt local remote
기술
pssh provides a number of commands for executing against a group of computers, using SSH. It's most useful for operating on clusters of homogenously-configured hosts. parallel-scp copy files in parallel to a set of machines.
출처 : 우분투 맨 페이지
예, parallel-scp를 설치하려면 pssh 패키지를 설치해야합니다.
sudo apt install pssh
그러면 명령이 표시됩니다 ( man parallel-scp 참조 ).
man parallel-scp
NAME
parallel-scp — parallel process kill program
SYNOPSIS
parallel-scp [-vAr] [-h hosts_file] [-H [user@]host[:port]] [-l user] [-p par]
[-o outdir] [-e errdir] [-t timeout] [-O options] [-x args] [-X arg] local
remote
DESCRIPTION
parallel-scp is a program for copying files in parallel to a number of hosts.
It provides features such as passing a password to scp, saving output to
files, and timing out.
OPTIONS
-h host_file
--hosts host_file
Read hosts from the given host_file. Lines in the host file are of the
form [user@]host[:port] and can include blank lines and comments (lines
beginning with "#"). If multiple host files are given (the -h option
is used more than once), then parallel-scp behaves as though these
files were concatenated together. If a host is specified multiple
times, then parallel-scp will connect the given number of times.
-H [user@]host[:port]
--host [user@]host[:port]
-H "[user@]host[:port] [ [user@]host[:port ] ... ]"
--host "[user@]host[:port] [ [user@]host[:port ] ... ]"
Add the given host strings to the list of hosts. This option may be
given multiple times, and may be used in conjunction with the -h
option.
-l user
--user user
Use the given username as the default for any host entries that don't
specifically specify a user.
-p parallelism
--par parallelism
Use the given number as the maximum number of concurrent connections.
-t timeout
--timeout timeout
Make connections time out after the given number of seconds. With a
value of 0, parallel-scp will not timeout any connections.
-o outdir
--outdir outdir
Save standard output to files in the given directory. Filenames are of
the form [user@]host[:port][.num] where the user and port are only
included for hosts that explicitly specify them. The number is a
counter that is incremented each time for hosts that are specified more
than once.
-e errdir
--errdir errdir
Save standard error to files in the given directory. Filenames are of
the same form as with the -o option.
-x args
--extra-args args
Passes extra SSH command-line arguments (see the ssh(1) man page for
more information about SSH arguments). This option may be specified
multiple times. The arguments are processed to split on whitespace,
protect text within quotes, and escape with backslashes. To pass argu‐
ments without such processing, use the -X option instead.
-X arg
--extra-arg arg
Passes a single SSH command-line argument (see the ssh(1) man page for
more information about SSH arguments). Unlike the -x option, no pro‐
cessing is performed on the argument, including word splitting. To
pass multiple command-line arguments, use the option once for each
argument.
-O options
--options options
SSH options in the format used in the SSH configuration file (see the
ssh_config(5) man page for more information). This option may be spec‐
ified multiple times.
-A
--askpass
Prompt for a password and pass it to ssh. The password may be used for
either to unlock a key or for password authentication. The password is
transferred in a fairly secure manner (e.g., it will not show up in
argument lists). However, be aware that a root user on your system
could potentially intercept the password.
-v
--verbose
Include error messages from ssh with the -i and \ options.
-r
--recursive
Recursively copy directories.
모든 대상 시스템에 적절한 ssh 키 구성이 있다고 가정하면 로그인하기 위해 비밀번호를 입력 할 필요가 없습니다.
#!/bin/bash
FILE="/put/your/file/here.txt"
TARGET_PATH="/where/to/put/on/remote/system/"
MACHINES="machine1 machine2 machine3"
for current_machine in $MACHINES; do
scp $FILE $current_machine:$TARGET_PATH
done
병렬로 수행하지는 않지만 다음에 하나씩 수행합니다. 그러나 각 명령을 개별적으로 입력 할 필요는 없으며 모두 자동으로 실행됩니다.
&
뒤에를 scp $FILE $current_machine:$TARGET_PATH
@NiteRain 제안처럼 기본적으로 병렬 실행을하지 않을 것이라고?
이 명령이 어떻게 사용되는지 몇 가지 예를 들어 보겠습니다.
설치하려면 sudo apt install pssh
다음 명령을 사용할 수 있습니다.
parallel-scp
: 병렬 프로세스 종료 프로그램parallel-ssh
: 병렬 ssh 프로그램parallel-rsync
: 병렬 프로세스 종료 프로그램parallel-slurp
: 병렬 프로세스 종료 프로그램parallel-nuke
: 병렬 프로세스 종료 프로그램형식에 따른 사용법 :
parallel-scp [-vAr] [-h hosts_file] [-H [user @] host [: port]] [-l 사용자] [-p par] [-o outdir] [-e errdir] [-t time‐ out] [-O 옵션] [-x args] [-X arg] [-L localdir] 원격 로컬
사용 예 :
호스트 이름을 읽을 hosts
파일을 작성하면 파일 pssh
형식은 다음과 같습니다.
[user@]host[:port]
따라서 george@192.168.3.30 : 333
Each should be on a different line and comments are preceeded by a `#` character
실제 복사 명령 :
parallel-scp -h /path/to/hosts/file src dest
모든 서버에서 $ HOME / demo.txt tp / tmp /를 복사하려면 다음을 수행하십시오.
parallel-scp -h /path/to/hosts/file $HOME/demo.txt /tmp/
보너스
모든 서버에서 명령을 실행하십시오.
parallel-ssh -i -h /path/to/hosts/file uptime
모든 서버에서 프로세스를 종료하십시오.
parallel-nuke -h /path/to/hosts/file firefox
출처 : https://www.cyberciti.biz/cloud-computing/how-to-use-pssh-parallel-ssh-program-on-linux-unix/