MSCP(1)
πΈ mscp(1) β copy files over multiple SSH connections πΈ
okay bestie, welcome to the MSCP(1) User Commands page. This is all about mscp, the tool that copies files over multiple SSH connections and is lowkey iconic for it. π
π NAME π
mscp β copy files over multiple SSH connections. periodt.
β¨ SYNOPSIS β¨
mscp [-46vqDpdNh] [-n NR_CONNECTIONS] [-m COREMASK] [-u MAX_STARTUPS]
[-I INTERVAL] [-W CHECKPOINT] [-R CHECKPOINT] [-s MIN_CHUNK_SIZE]
[-S MAX_CHUNK_SIZE] [-a NR_AHEAD] [-b BUF_SIZE] [-L LIMIT_BITRATE]
[-l LOGIN_NAME] [-P PORT] [-F SSH_CONFIG] [-o SSH_OPTION] [-i IDENTITY]
[-J DESTINATION] [-c CIPHER] [-M HMAC] [-C COMPRESS] [-g CONGESTION]
source ... target
π¦ DESCRIPTION π¦
so here's the tea: mscp copies files over multiple SSH (SFTP) connections by multiple threads. It lets you transfer (1) multiple files simultaneously and (2) a large file in parallel, which reduces the transfer time for a lot of/large files over networks. β¨
Usage follows the scp command of OpenSSH, like this:
$ mscp srcfile user@example.com:dstfile
Remote hosts only need to run standard sshd supporting the SFTP subsystem, and users need to be able to ssh to the hosts as usual. mscp does not require anything else. π«Ά
mscp uses libssh as its SSH implementation. So supported SSH features β authentication, encryption, and various options in ssh_config β follow what libssh supports. iykyk.
π OPTIONS π
-n NR_CONNECTIONSβ says how many SSH connections to use. The default is calculated from the number of CPU cores on the host with this formula:floor(log(nr_cores)*2)+1.-m COREMASKβ picks CPU cores using a hexadecimal bitmask. For example,-m 0x25pins threads onto CPU cores 0, 2, and 5. The default value is not specified: all CPU cores are used and no threads are pinned to any cores.-u MAX_STARTUPSβ says how many concurrent unauthenticated SSH connection attempts are allowed.sshdlimits simultaneous SSH connection attempts withMaxStartupsinsshd_config. The defaultMaxStartupsis 10; thus, the defaultMAX_STARTUPSis set to 8.-I INTERVALβ sets the interval in seconds between SSH connection attempts. Some firewall products treat SSH connection attempts from a single source IP address for a short period as a brute force attack. This option inserts intervals between the attempts to avoid being determined as an attack. The default value is 0.-W CHECKPOINTβ gives a checkpoint file to save the state of a failed transfer. When transferring fails due to, for example, connection disruption or user interrupt,mscpwrites the information about the remaining files and chunks to the specified checkpoint file.-Woption with-D(dry-run mode) only writes a checkpoint file and exits.-R CHECKPOINTβ gives a checkpoint file to resume a transfer. When a checkpoint file is passed,mscpreads the checkpoint to load a remote host, copy direction, and files and their chunks to be transferred. Namely,mscpcan resume a past failed transfer from the checkpoint. Resuming with a checkpoint does not requiresource ... targetarguments. Other SSH connection options, such as port number and config file, should be specified as with the failed run. In addition, checkpoint files have file paths as relative paths. Thus, you must runmscpin the same working directory as the failed run. You can see the contents of a checkpoint file with themscp -vv -D -R CHECKPOINTcommand (Dry-run mode). Note that the checkpoint file is not automatically removed after the resumed transfer ends successfully. Users should check the return value ofmscpand remove the checkpoint if it returns 0.-s MIN_CHUNK_SIZEβ sets the minimum chunk size.mscpdivides a single file into chunks and copies the chunks in parallel. The default value is 16M bytes.-S MAX_CHUNK_SIZEβ sets the maximum chunk size. The default is file size divided by the number of connections and devided by 4. If the calculated value is smarller than theMIN_CHUNK_SIZEvalue,MIN_CHUNK_SIZEis used.-a NR_AHEADβ sets the number of inflight SFTP commands. The default value is 32.-b BUF_SIZEβ sets the buffer size for I/O and transfer over SFTP. The default value is 16384. Note that the SSH specification restricts buffer size delivered over SSH. Changing this value is not recommended at present.-L LIMIT_BITRATEβ limits the bitrate, specified withk(K),m(M), andg(G), e.g.,100mindicates 100 Mbps.-4β uses IPv4 addresses only.-6β uses IPv6 addresses only.-vβ increments the verbose output level.-qβ quiet mode: turns off all outputs.-Dβ dry-run mode: it scans source files to be copied, calculates chunks, resolves destination file paths, and exits. Dry-run mode with-vvoption can confirm files to be copied and their destination paths.-rβ no effect.mscpcopies recursively if a source path is a directory. This option exists for just compatibility.-l LOGIN_NAMEβ specifies the username to log in on the remote machine as withssh(1).-P PORTβ specifies the port number to connect to on the remote machine as withscp(1).-F SSH_CONFIGβ specifies an alternative per-user ssh configuration file. Note that acceptable options in the configuration file are whatlibsshsupports.-o SSH_OPTIONβ specifies ssh options in the format used inssh_config. Note that acceptable options are whatlibsshsupports.-i IDENTITYβ specifies the identity file for public key authentication.-J DESTINATIONβ a shortcut to define aProxyJumpconfiguration directive. Each SFTP session ofmscpconnects to the target host by first making an ssh connection to the jump host described by destination.-c CIPHERβ selects the cipher to use for encrypting the data transfer. Seemscp -horCiphersin libssh features.-M HMACβ specifies MAC hash algorithms. Seemscp -horMAC hashesin libssh features.-C COMPRESSβ enables compression:yes,no,zlib,zlib@openssh.com. The default is none. See libssh features.-g CONGESTIONβ specifies the TCP congestion control algorithm to use (Linux only). Seesysctl net.ipv4.tcp_allowed_congestion_controlfor available values.-pβ preserves modification times and access times (file mode bits are preserved by default).-dβ increments the ssh debug output level.-Nβ enables Nagle's algorithm. It is disabled by default.-hβ prints help.
π EXIT STATUS π
Exit status is 0 on success, and >0 if an error occurs.
π§ ENVIRONMENT π§
mscp recognizes the following environment variables.
MSCP_SSH_AUTH_PASSWORDβ this environment variable passes a password for password authentication to establish SSH connections.MSCP_SSH_AUTH_PASSPHRASEβ this environment variable passes a passphrase for public-key authentication for establishing SSH connections.
π NOTES π
mscpusesglob(3)for globbing pathnames, including matching patterns for local and remote paths. However, globbing on the remote side does not work with musl libc (used in Alpine Linux and the single-binary version ofmscp) because musl libc does not supportGLOB_ALTDIRFUNC.mscpdoes not support remote-to-remote copy, whichscpsupports.
π EXAMPLES π
Copy a local file to a remote host with different name:
$ mscp ~/src-file 10.0.0.1:copied-file
Copy a local file and a directory to /tmp at a remote host:
$ mscp ~/src-file dir1 10.0.0.1:/tmp
Save a checkpoint if transfer fails:
$ mscp -W mscp.checkpoint many-large-files 10.0.0.1:dst/
Check the remaining files and chunks, and resume the failed transfer:
# Dump the content of a checkpoint and exit (dry-run mode)
$ mscp -vv -D -R mscp.checkpoint
# resume transferring from the checkpoint
$ mscp -R mscp.checkpoint
In a long fat network, following options might improve performance:
$ mscp -n 64 -m 0xffff -a 64 -c aes128-gcm@openssh.com src 10.0.0.1:
-n increases the number of SSH connections than default, -m pins threads to specific CPU cores, -a increases asynchronous inflight SFTP WRITE/READ commands, and -c aes128-gcm@openssh.com will be faster than the default chacha20-poly1305 cipher, particularly on hosts that support AES-NI.
π SEE ALSO π
π₯ PAPER REFERENCE π₯
Ryo Nakamura and Yohei Kuga. 2023. Multi-threaded scp: Easy and Fast File Transfer over SSH. In Practice and Experience in Advanced Research Computing (PEARC '23). Association for Computing Machinery, New York, NY, USA, 320β323. DOI.
π CONTACT INFORMATION π
For patches, bug reports, or feature requests, please open an issue on GitHub.
β AUTHORS β
Ryo Nakamura <upa@haeena.net>
Final sign-off, bestie: this page is for mscp v0.2.4 from the MSCP(1) manual. The footer didn't list a date, so we're not making one up. πππ¦
π¦ where this page comes from
- arch rolling: mscp 0.2.4-1 Β· GPL-3.0-only
- nixpkgs unstable: mscp 0.2.4
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms