Skip to main content

Command-Line SFTP Examples

Many operating systems include the OpenSSH sftp clientExternal LinkThis link leads to an external website and will open in a new tab. These examples cover its interactive commands.

Files.com recommends using our own Command Line Interface (CLI) app instead of the sftp command. The examples below cover the common operations for customers who are required to use sftp.

Connecting and Authenticating

To connect to Files.com, specify your username and the fully qualified domain name (FQDN) of your Files.com site, separated by an @ character:

sftp username@MYCOMPANY.files.com

When prompted, enter your password.

Connecting and Authenticating With an SSH/SFTP Key

Register your public SSH key with your Files.com user. Keep the matching private key on your computer, for example in my_ssh_key.key. The -i option below refers to that private key.

The key file must have restricted access permissions so that only your user ID can read it. Remove access for Groups and Everyone, leaving only read permission for yourself.

Connect to Files.com, specifying the key file with the -i (identity file) flag.

For Mac/Linux:

sftp -i /path/to/my_ssh_key.key username@MYCOMPANY.files.com

For Windows:

sftp -i C:\path\to\my_ssh_key.key username@MYCOMPANY.files.com

Uploading Files

Upload a single file using the put command:

put file.ext

Upload files with separate commands:

put file1.ext
put file2.ext
put file3.ext

A wildcard matches and uploads multiple file names at once:

mput file*.ext

Uploading a Folder

Create the destination folder using the mkdir (make directory) command. The folder name must match the name of the folder you're uploading:

mkdir TheFolderName

Then upload the folder contents using the put -r (put recursively) command:

put -r TheFolderName/

Downloading Files

Download a single file using the get command:

get file.ext

Download files with separate commands:

get file1.ext
get file2.ext
get file3.ext

A wildcard matches and downloads multiple file names at once:

mget file*.ext

Downloading a Folder

Create the local destination folder using the lmkdir (locally make directory) command. The folder name must match the name of the folder you're downloading:

lmkdir TheFolderName

Download the folder contents using the get -r (get recursively) command:

get -r TheFolderName/

If a download fails with a local permission error, check that your user can write to the destination directory. The optional lumask command controls permissions on newly created local files; a particular mask is not required for every download.