Home /  SFTP / 

Using Stedi SFTP from the command line

This example shows how to use the SFTP service from the command line.


Create an API key if you haven’t done so already. The examples on this page assume you have your API key stored in an environment variable called STEDI_API_KEY. You can do that with the following command.
export STEDI_API_KEY=replace.withYourOwnApiKey

Create an SFTP user

Create a user by calling the Stedi SFTP API. You can customize description, homeDirectory and passwordOptions.
  • description helps you find the user account later if you need to.
  • homeDirectory determines which files and directory the user has access to. The user can access any file or directory under their home directory, but none outside of it.
  • passwordOptions determines how the password is generated.
    • length determines the length of the password.
curl --request POST 'https://api.sftp.us.stedi.com/2022-04-01/users' \
    --header "Authorization: Key ${STEDI_API_KEY}" \
    --header 'Content-Type: application/json' \
    --data-raw '{
        "homeDirectory": "/directory/for/partner1",
        "description": "Trading Partner 1"

The response will look something like this.

  "username": "WL9F11A9",
  "homeDirectory": "/directory/for/partner1",
  "description": "Trading Partner 1",
  "bucketName": "565460e4-4c6f-4a55-87f1-a9d27616f8aa-sftp",
  "endpoint": "transfer.us.stedi.com",
  "password": "k9TqUSvZsGPs9iav"

Connect to the SFTP endpoint

You can use the returned credentials to connect to the SFTP endpoint. You can use whichever SFTP client you prefer. In this example, we’ll access the endpoint from the command line.

sftp WL9F11A9@transfer.us.stedi.com

The client will ask for your password. After that, you will see the following prompt.


You can type in commands to interact with the SFTP endpoint. If you’re not familiar with SFTP commands, here are a few common ones to get you started.

pwdShow the name of the active directory on the SFTP endpoint.
lpwdShow the name of the active directory on your local machine.
lsList the contents of the active directory on the SFTP endpoint.
llsList the contents of the active directory on your local machine.
cdChange the active directory on the SFTP endpoint, e.g. cd documents.
lcdChange the active directory on your local machine, e.g. cd documents.
mkdirCreate a directory on the SFTP endpoint, e.g. mkdir documents.
getDownload a file from the SFTP endpoint to your local machine, e.g. get file.txt.
putUpload a file from your local machine to the SFTP endpoint, e.g. put file.txt.
renameChange the name of a file on the SFTP endpoint, e.g. rename file.txt document.txt.
rmRemove a file from the SFTP endpoint, e.g. rm document.txt.
byeDisconnect from the SFTP endpoint.
AuthenticationCreate an SFTP userConnect to the SFTP endpoint


Have an idea for something we could improve? Page not clear? We love feedback - send us a message.


Build EDI integrations fast, without being an EDI expert

Start building
  1. Twitter
  2. GitHub
Backed by
AdditionBloomberg BetaFirst RoundStripeUSV
Customer AgreementService TermsPrivacy Notice

Stedi is a registered trademark of Stedi, Inc. All names, logos, and brands of third parties listed on our site are trademarks of their respective owners (including “X12”, which is a trademark of X12 Incorporated). Stedi, Inc. and its products and services are not endorsed by, sponsored by, or affiliated with these third parties. Our use of these names, logos, and brands is for identification purposes only, and does not imply any such endorsement, sponsorship, or affiliation.