Manipulating System Files
To manage the system files, you might want to transfer a configuration file to a remote system to back up the file, or obtain from a remote system an update or backup file. To access the remote system, you probably need a username and password. This section provides some example commands for performing these tasks.
Manipulating Files on a Network Server
To specify a file on a network server, use one of the following forms:
- ftp://<username>:<password>@server/filename
- scp://<username>:<password>@server/filename
- sftp://<username>:<password>@server/filename
- tftp://server/filename
The server can either be an IP address or host name. The username, if specified, overrides a username specified by the global configuration command ip ftp username. A password also overrides a password specified by the global configuration command ip ftp password.
The specified directory and filename are relative to the directory used for file transfers, or in absolute format.
Manipulating System Files
The following example uses secure FTP to access the file named meru-3.7-config on a server named ftp.fortinet.com. This example uses the username admin and the password secret to access this server: controller# copy sftp://admin:secret@ftp.fortinet.com/meru-3.7-config<space>.
For SCP (secure copy), replace the prefix sftp with scp.
Remote File Transfer Tasks
On a remote file system located on an FTP, SFTP, TFTP or SSH server, you can perform the following tasks:
- Copy files to or from the controller using the copy command.
- List the files in a given directory using the dir command.
Copying Files to a Remote Server
For example, to copy a backup image jun01.backup.mbu from the local directory images to a remote directory /home/backup on server server1, with user user1 using FTP, with the same remote filename, type:
controller# cd images controller# dir total 48
‐rw‐r‐‐r‐‐ 1 root root 15317 Jan 9 15:46 jun01.backup.mbu
controller# copy jun01.backup.mbu ftp://user1@server1/home/backup/. FTP Password: controller#
Type the password for user user1 at the FTP Password prompt. To use SCP instead of FTP:
controller# copy jun01.backup.mbu scp://user1@server1/home/backup/.
SCP Password:
Displaying a Remote Server’s Directory Contents
To display the contents of the remote directory /home/backup on the server server1, for the username user1 and password userpass, you can type: controller# dir ftp://user1:userpass@server1/home/backup
If you only specify the user name but not the password, the CLI prompts you to enter the password:
controller# dir ftp://user1@server1/home/backup FTP Password:
Manipulating System Files
Setting a Remote Username and Password
The secure remote file transfer commands require a remote username and password on each request to a server. The CLI uses the user name and password specified in the dir or copy command to authenticate with the remote file servers.
If you do not want to type the user name and password for each secure remote file transfer command, you can set these values for the duration of your session using the ip ftp, ip sftp, or ip scp commands.
For example, to set the FTP user name to user1 and the FTP password to userpass, type:
controller# configure terminal controller(config)# ip ftp username user1 controller(config)# ip ftp password userpass controller(config)# ^Z controller#
Likewise, to set the SCP user name to user1 and the SCP password to userpass, type:
controller# configure terminal controller(config)# ip scp username user1 controller(config)# ip scp password userpass controller(config)# ^Z controller#
If you have set the FTP username and password as in the previous example, you can now type the following: controller# dir ftp://server1/home/backup