# 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.

### To Connect and Authenticate

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

`sftp username@MYCOMPANY.com`

When prompted, enter your password.

### To Connect and Authenticate Using an SSH/SFTP Key

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

Restrict access permissions on the key file so that only your user ID can access it. Remove access permissions for Groups and Everyone, leaving only read permission for yourself.

Connect to ExaVault and specify the Key file with the `-i` (identity file) flag.

For Mac/Linux:

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

For Windows:

`sftp -i C:\path\to\my_ssh_key.key username@MYCOMPANY.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 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, with a folder name that matches 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/`

### 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 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, with a folder name that matches 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 the downloaded files the correct permissions. Without this step, subfolders may be created while the files inside them fail to download due to permission errors.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.exavault.com/connection-methods/sftp/command-line-sftp-examples.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
