Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

header-navigation
keyboard_arrow_up
close
keyboard_arrow_left
Junos CLI Reference
Table of Contents Expand all
list Table of Contents
file_download PDF
{ "lLangCode": "en", "lName": "English", "lCountryCode": "us", "transcode": "en_US" }
English
keyboard_arrow_right

file copy

date_range 20-Feb-25

Syntax (Junos OS)

content_copy zoom_out_map
file copy source destination
<no-stage>
<routing-instance routing-instance-name>
<source-address source-address>
<staging-directory directory-location>

Syntax (Junos OS Evolved)

content_copy zoom_out_map
file copy source destination
<no-check-certificate>
<routing-instance routing-instance-name>
<source-address source-address>
<staging-directory directory-location>

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

content_copy zoom_out_map
user@host> file copy /var/tmp/rpd.core.4 mypc:/c/junipero/tmp

...transferring.file...... |          0 KB |   0.3 kB/s | ETA: 00:00:00 | 100%

Copy a Configuration File between Routing Engines

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

content_copy zoom_out_map
user@host> file copy /config/juniper.conf re1:/var/tmp/copied-juniper.conf

Copy a File Using Secure Copy Protocol

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

content_copy zoom_out_map
user@host> file copy /var/log/messages scp://10.1.1.1/home/user/archive
user@10.1.1.1's password:
messages                                                               100%  521KB   1.6MB/s   00:00

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

content_copy zoom_out_map
user@host> file copy /var/log/messages scp://user1@10.1.1.1/home/user1/archive
user1@10.1.1.1's password:
messages                                                               100%  521KB   1.6MB/s   00:00

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:

content_copy zoom_out_map
root@host> file copy filename ftp://user@hostname/filename                  

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

content_copy zoom_out_map
root@host> file copy /config/juniper.conf ftp://user@hostname/juniper.conf
Password: 
Receiving ftp: //user@hostname/juniper.conf (2198 bytes): 100%
2198 bytes transferred in 0.0 seconds (2.69 MBps)
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.

content_copy zoom_out_map
user@host> file copy re1:/var/tmp/junos-install-x.log /root/ staging-directory /var/tmp/tmp1

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.

footer-navigation