Command-Line SFTP Examples


Many operating systems come with a built in sftp command that can be used to connect and perform operations via SFTP. Our typical caveats about SFTP apply.

Files.com recommends that you instead use our own Command Line Interface (CLI) app as opposed to using the SFTP command.

If you are required to use the sftp command, this article provides examples for how to use it with Files.com

To connect and authenticate

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.

To connect and authenticate using a SSH/SFTP Key

Save the SSH/SFTP Key to a file on your computer. For example, my_ssh_key.key

Make sure that the key file has restricted access permissions, so that only your user ID can access the file. Remove the access permissions for Groups and Everyone, leaving only read permission for yourself.

Connect to Files.com, specifying the Key file by using 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

To upload 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

Or you can use a wildcard to match and upload multiple file names:

mput file*.ext

To upload a folder

Create the destination folder using the mkdir (make directory) command and make sure the folder name matches the name of the folder you’re trying to upload:

mkdir TheFolderName

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

put -r TheFolderName/

To download 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

Or you can use a wildcard to match and download multiple file names:

mget file*.ext

To download a folder

Create the local destination folder using the lmkdir (locally make directory) command and make sure the folder name matches the name of the folder you’re trying to download:

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/

Using the lumask command to set the UMASK to 002 will set the correct permissions for all the files to download successfully. If you miss this step then you might see permission errors, where subfolders will be created but the files contained within them will fail to download.

Get Instant Access to Files.com

The button below will take you to our Free Trial signup page. Click on the white "Start My Free Trial" button, then fill out the short form on the next page. Your account will be activated instantly. You can dive in and start yourself or let us help. The choice is yours.

Start My Free Trial

©2024 Files.com. All right reserved

FILES.COM

  • Start My Free Trial
  • Pricing
  • Docs
  • API and SDKs
  • Contact

CONTACT & SUPPORT

support@files.com

(800) 286-8372

Monday–Friday

9am–8pm Eastern