Skip to main content

Command-Line SFTP Examples

Many operating systems include a built-in sftp command for connecting and performing operations over SFTP. Our typical caveats about SFTP apply.

Files.com recommends using our own Command Line Interface (CLI) appExternal LinkThis link leads to an external website and will open in a new tab 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

Save the SSH/SFTP Key to a file on your computer. For example, my_ssh_key.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 multiple files using the mput (multiple put) command:

mput file1.ext file2.ext 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 multiple files using the mget (multiple get) command:

mget file1.ext file2.ext 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

Set your local permissions using the lumask (locally set the mask for user permissions) command:

lumask 002

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

get -r TheFolderName/

Setting the UMASK to 002 with lumask gives all downloaded files the correct permissions. Skipping this step causes permission errors where subfolders are created but the files inside them fail to download.