sftp icon

SFTP

Version: latest

When you want to send and receive a large amount of files via the AS2 Gateway, using an integration mechanism is a must. SFTP is one such integration mechanisms currently supported by the AS2 Gateway.

What is SFTP?

SFTP, which stands for SSH File Transfer Protocol, or Secure File Transfer Protocol, is a separate protocol packaged with SSH that works in a similar way over a secure connection. The advantage is the ability to leverage a secure connection to transfer files and traverse the filesystem on both the local and remote system.

The AS2 Gateway runs an SFTP server and once the SFTP setup is done, users can login to the AS2 Gateway’s SFTP server to download received files and upload files to be sent.

Setup SFTP with AS2 Gateway

Lets start with setting up SFTP for your account. First go to the SFTP view using the "SFTP" icon on the left navigation menu. Alternatively click on the link https://console.as2gateway.com/sftp to navigate to the SFTP view.

sftp menu

One you navigate to the SFTP view, if you haven’t already done the SFTP setup, a form will be shown with a username and a password field.

Please provide a user name and a password and click on Setup SFTP to initiate the SFTP setup.

Username should start from a lowercase character and it can only include numbers 0-9, hyphen and underscore. Uppercase characters are not allowed.

Minimum length for the password field is 5 characters.

Once you click on the "Setup SFTP" button, what happens in the background is that a key-based authentication for SFTP will be setup for you and your private key will be available for you to download after the setup. Note that the password which you provided during the setup will be the passphrase for your private key.

Once the SFTP setup is complete, you should be able to use any of the SFTP clients and connect to the AS2 Gateway server. After the setup the SFTP view will show the instructions on connecting to the AS2 Gateway SFTP server via the command line for Linux and MacOS users. In this documentation we will cover steps on configuring connectivity using several SFTP clients including OpenSSL command line client and File Zilla and WinSCP.

A complete listing of SFTP clients can be found at https://www.sftp.net/clients

Logging in with Command Line in Unix Systems (Linux and MacOS)

If you want to access SFTP from a script or if you simply prefer command line over GUI, this is the option to go with.

Nowadays `sftp` command is available by default in most Unix systems. If the `sftp` command is not available in your
system please install link:http://www.openssh.com/[OpenSSH^] which includes an SFTP command line client.
  1. First download the private key file from the SFTP view.

  2. Then before using the login command, we first have to set correct permissions to the private key file. In-order to set the correct permission, navigate to the directory where the downloaded private key file is stored and run the below command. Remember to replace the <private_key_file> part with the actual private key file name when you execute the below command.

    sudo chmod 400 <private_key_file>

    Note that if you do not set correct permission to the private key file, you’ll get an error message similar fo following when you try to run the SFTP login command.

    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    Permissions 0777 for 'id_rsa_rajind' are too open.
    It is required that your private key files are NOT accessible by others.
    This private key will be ignored.
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    Permissions 0777 for 'id_rsa_rajind' are too open.
    It is required that your private key files are NOT accessible by others.
    This private key will be ignored.
    Load key "id_rsa_rajind": bad permissions
    rajind@sftp.as2gateway.com: Permission denied (publickey).
    Connection closed
  3. Now you can run the SFTP login command as follows. Please replace <private_key_file with the your private key file name with path and replace <user_name> with the SFTP username (the username which was used in the form when setting up SFTP) when executing the below command.

    Note that at the first time when you run the sftp login command, you will be prompted for the private key passphrase. Please provide the password which you used in the form when setting up SFTP as the passphrase.

    sftp -o Port=9193 -o IdentityFile=<private_key_file> <user_name>@sftp.as2gateway.com

Logging in with OpenSSH Command Line SFTP Client in Windows Systems

In this section we’ll look into how we can login to the AS2 Gateway SFTP server from a Windows based OpenSSH command line client. If the sftp command is not available in your cmd, please install OpenSSH before proceeding further.

  1. First download the private key file from the SFTP view.

  2. Then before using the login command, we first have to set correct permissions to the private key file. Please take a look at this Super User thread of setting correct permissions to your private key file.

    Note that if you do not set correct permission to the private key file, you’ll get an error message similar fo following when you try to run the SFTP login command.

    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    Permissions 0777 for 'id_rsa_rajind' are too open.
    It is required that your private key files are NOT accessible by others.
    This private key will be ignored.
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    Permissions 0777 for 'id_rsa_rajind' are too open.
    It is required that your private key files are NOT accessible by others.
    This private key will be ignored.
    Load key "id_rsa_rajind": bad permissions
    rajind@sftp.as2gateway.com: Permission denied (publickey).
    Connection closed
  3. Now you can run the SFTP login command as follows. Please replace <private_key_file with the your private key file name with path and replace <user_name> with the SFTP username (the username which was used in the form when setting up SFTP) when executing the below command.

    Note that at the first time when you run the sftp login command, you will be prompted for the private key passphrase. Please provide the password which you used in the form when setting up SFTP as the passphrase.

    sftp -o Port=9193 -o IdentityFile=<private_key_file> <user_name>@sftp.as2gateway.com
In this topic
In this topic