Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

file copy

Syntax (Junos OS)

Syntax (Junos OS Evolved)

Description

Copy files from one location to another location on the local device or to or from a location on a remote device reachable by the local device.

The source and destination can specify local paths and FTP, HTTP, HTTPS, and SCP URLs. For information on valid file name and URL formats, see Format for Specifying Filenames and URLs in Junos OS CLI Commands.

When you use the file copy command to transfer a file from a remote location to the Junos device or from the other Routing Engine to the local Routing Engine, the operation uses a temporary staging directory during the file transfer. The root user's staging directory is under /var/tmp, and the non-root user staging directory is the under the user's home directory. When the file transfer is complete, the file is moved to the destination directory. Thus, for these transfers, the staging directory must have space equal to the file's size, and the device must have space equal to twice the file's size.

Large files may exceed the space available in the default staging directory or on the device causing the file transfer to fail. If the staging directory has insuffient space, you can use the staging-directory option to specify a different staging directory with more space. If the device has limited space, you can specify the no-stage option to bypass the staging directory and transfer the file directly to the destination directory.

Note:

If you define an ordered set of ciphers, key exhange methods, or message authentication codes (MACs) at the [edit system services ssh] hierarchy level, the newly-defined set is used when copying files using secure copy protocol (scp). For more information, see Configuring the SSH Service to Support Legacy Cryptography.

Options

source

Specify the source URL.

destination

Specify the destination URL.

no-check-certificate

Bypass certificate validity checks when downloading a file from an HTTPS URL. We recommend that you use this option only when the server is known and trusted.

no-stage

Download a file directly to the destination directory of the device running Junos OS rather than store it in the staging directory during the file transfer.

You can use this option to download files to a device where space is limited. By bypassing the staging directory, the device only requires space equal to the file's size.

Note:

If you include the no-stage option and the file tranfer fails, an existing file with the same name in the destination directory can be overwritten.

routing-instance routing-instance-name

(Optional) Specify the routing-instance to use for the connection.

source-address source-address

(Optional) Specify the local address to use in originating the connection.

staging-directory directory-location

(Optional) Specify the staging directory on the Routing Engine where a downloaded file is temporarily staged during the file transfer. Use this option when the default staging directory does not have enough space available to temporarily store the file during transfer.

  • Default:

    (Root user) /var/tmp/

    (Non-root user) /var/home/username/

Note:

If you are using a literal IPv6 address in your command entry, the address must be enclosed in [ ] brackets. This conforms to RFC 2732.

Required Privilege Level

maintenance

Sample Output

Following are some file copy examples.

Copy a File from the Local Device to a Personal Computer

Copy a Configuration File between Routing Engines

The following sample command copies a configuration file from Routing Engine 0 to Routing Engine 1:

Copy a File Using Secure Copy Protocol

The following command uses SCP to copy a file to a remote server:

The following command uses SCP to copy a file to a remote server as a different user:

Copy a File Using File Transfer Protocol which Requires a Password

You can use FTP with the file copy command for additional privacy. You will be prompted for a password. Enter the following command to enable FTP:

In the following example, /config/juniper.conf is the local file and hostname is the FTP server:

Note:

Starting in Junos OS Evolved release 22.2R2, the password prompt has changed from Password for user@hostname: to Password:

Copy a File Using a Staging Directory

The following sample command copies a file and uses a staging directory that is different from the default.

Release Information

Command introduced before Junos OS Release 7.4.

source-address option added in Junos OS Release 7.4.

staging-directory option added in Junos OS Release 17.3R1.

no-check-certificate option added in Junos OS Evolved Release 23.1R1.

no-stage option added in Junos OS Release 24.2R1.