All guides

Command line (sftp and scp)

The sftp and scp commands built into macOS, Linux and Windows 10 and 11.

sftp opens an interactive session where you browse folders and move files; scp copies files in one command, which suits scripts. Both come with OpenSSH, which is built into macOS, Linux and Windows 10 and 11 (PowerShell or Command Prompt). Replace sftpuser_acme-jane with your login and the key path with yours.

Connect with sftp

  1. Open a terminal: Terminal on macOS, a shell on Linux, or PowerShell on Windows.
  2. Connect with your SSH key:
    sftp -i ~/.ssh/id_ed25519 -P 22 [email protected]
    If your organization allows passwords, leave out -i ~/.ssh/id_ed25519 and type your password when asked.
  3. The first time you connect, sftp shows the server's key fingerprint and asks whether to continue. Compare it with the one in the portal (Get started, step Connect). Type yes only if they match.
  4. At the sftp> prompt, use these commands:
    sftp commands
    CommandWhat it does
    pwdshow the current folder
    lslist files
    cd /inbox/acmechange folder
    put report.csvupload a file
    put -r outgoingupload a folder and everything in it
    get orders.csvdownload a file
    get -r archivedownload a folder
    mkdir new-foldercreate a folder
    rename old.csv new.csvrename a file
    rm old.csvdelete a file
    lcd ~/Downloadschange the folder on your computer
    exitdisconnect
    What you can do depends on your login's access in the portal; a download-only login cannot upload or delete, for example.

Run sftp from a script

  1. Put the commands in a file, one per line, for example upload.txt:
    cd /inbox/acme
    put report.csv
  2. Then run it. With -b, sftp stops at the first failed command and exits with an error, which a scheduled job can check. Batch mode needs key login: it cannot ask for a password.
    sftp -b upload.txt -i ~/.ssh/id_ed25519 -P 22 [email protected]

Copy files with scp

  1. Upload a file into a folder (the trailing slash keeps the file's name):
    scp -i ~/.ssh/id_ed25519 -P 22 report.csv [email protected]:/inbox/acme/
  2. Download a file into the current folder on your computer:
    scp -i ~/.ssh/id_ed25519 -P 22 [email protected]:/outbox/orders.csv .
  3. Copy a whole folder with -r:
    scp -r -i ~/.ssh/id_ed25519 -P 22 outgoing [email protected]:/inbox/acme/

There is no shell: ssh to the server to run commands is not available. Use sftp or scp to work with your files.

File times and permissions

sftp's put -p and scp -p try to keep each file's time and permissions. The server accepts the request, and the file keeps its upload time.

Files keep the time they were uploaded, and the server has no Unix file permissions. Over SFTP, a client that sets a file's time or permissions after an upload gets a success reply and nothing changes; over FTPS the same holds for the time. Who can read or change files is set by your organization in the portal.

Verify the server on first connect: compare the host key fingerprint your client shows with the one in the portal under Get started, step Connect. If they differ, do not continue and contact [email protected].