Free cookie consent management tool by TermsFeed AS2 Gateway - Message Exchange Using SFTP | Aayu Technologies Cookies preferences
Home Blog AS2 Gateway - Message Exchange Using SFTP

AS2 Gateway - Message Exchange Using SFTP

Integrate AS2 Gateway with SFTP for secure, automated file transfers. Enhance data security, compliance, and efficiency with seamless AS2-SFTP integration.

Gayana Sathsarani

In today’s digital landscape, secure and efficient data exchange is crucial for businesses. The AS2 Gateway supports SFTP (Secure File Transfer Protocol) for transmitting large files, enhancing security, reliability, and operational efficiency. This guide explains how to exchange messages using SFTP with AS2 Gateway.

Understanding AS2 Gateway and SFTP

What is AS2 Gateway?

AS2 Gateway is a secure message exchange solution that enables businesses to transmit files using the AS2 protocol. It supports on-premises, cloud, and containerized deployments and is available as a desktop application or hosted SaaS solution. While it does not natively support SFTP, it offers SFTP integration for submitting and retrieving AS2-transmitted files. AS2 Gateway ensures secure, scalable, and efficient file exchanges with multiple integration options like REST APIs, Webhooks, SFTP and AWS S3 integration.

What is SFTP?

SFTP operates over SSH (Secure Shell) and provides encrypted file transfer capabilities. Unlike traditional FTP, SFTP encrypts both commands and data, ensuring a secure file transfer environment. It is particularly useful when exchanging large amounts of files between systems securely.

Benefits of Integrating AS2 Gateway with SFTP

  1. Enhanced Security: Both protocols provide robust security measures, ensuring that sensitive business data is protected during transmission.

  2. Operational Efficiency: Allows for automated and scheduled file transfers, reducing manual intervention and potential errors.

  3. Regulatory Compliance: Helps businesses meet compliance standards, particularly in industries like healthcare and supply chain management (EDI X12), which require secure data exchanges.

  4. Automation Capability: Streamlines and automates file transfers for greater efficiency.

Enabling SFTP Integration in AS2 Gateway

The AS2 Gateway runs an SFTP server, allowing users to download received files and upload files for transmission.

Steps to Enable SFTP Integration

  1. Navigate to the SFTP Feature page in the AS2 Gateway interface by clicking the SFTP icon in the Integrations menu on the left navigation pane.

    If you have not already set up SFTP integration the below page will appear, allowing you to enable the integration.

    Enable SFTP Integration

  2. Provide the required details:
    • Username for SFTP login
    • Passphrase for the private key.
  3. Once you click on the ‘Setup SFTP’ button, key-based authentication for SFTP will be set up, and you can download your private key.

Once SFTP is set up, you can connect to the AS2 Gateway server using any SFTP client (e.g., OpenSSH, WinSCP, FileZilla) and exchange files securely.

Connecting via SFTP

AS2 Gateway SFTP Connection Information

  • Server: sftp.as2gateway.com

  • Port: 9193

  • Authentication: Key-based authentication

Connecting with OpenSSH (Linux/Mac)

After the setup completes, the SFTP view will show the instructions on connecting to the AS2 Gateway SFTP server via the command line for Linux and MacOS users.

Connecting with OpenSSH

  1. Download the private key from the SFTP view.

  2. Navigate to the directory where the private key resides through terminal and set correct file permissions using following command:

     sudo chmod 400 private_key_file
    
  3. Run the following SFTP login command to connect the AS2 Gateway SFTP server:

     sftp -P 9193 -i private_key_file <user_name>@sftp.as2gateway.com
    
  4. Enter the passphrase when prompted.(The first time you run the command, you will be asked for the private key passphrase)

Connecting with WinSCP (Windows)

  1. Open WinSCP and convert the private key into Putty format (PPK) using PuTTYgen.

  2. Create a New Site with the following details

    • Host: sftp.as2gateway.com

    • Port: 9193

    • User:

    • Authentication: Click ‘Advanced’ and use the PPK format private key file under SSH -> Authentication.

Connecting with WinSCP

  1. Save and connect to the AS2 Gateway SFTP server.

Connecting with FileZilla (Linux/Windows)

  1. Open FileZilla and create a New Site by providing the SFTP information.

  2. Set the logon type as a Key file.

  3. Select the key file downloaded from the AS2 Gateway. It will prompt you to convert the key and ask for the passphrase. Once entered, the key will be saved in PPK format at a location selected by you.

Connecting with FileZilla

  1. Save and connect to the AS2 Gateway SFTP server.

SFTP Folder Structure in AS2 Gateway

SFTP integration in AS2 Gateway follows a structured directory system

  1. Top-Level Directories:

    • .ssh: Contains configuration files related to SFTP login.

    • as2gateway: Main data directory.

  2. Inside as2gateway Folder:

    • Each AS2 Station has a corresponding folder:

    • Each AS2 Partner within a station has a folder: .

  3. Subdirectories under each AS2 Partner folder:

    • outbox: Files placed here will be sent via AS2.

    • inbox: Received AS2 messages are stored here.

    • failed: Files that failed to send are placed here.

Note that in AS2 Gateway, Test partners have their message folders inside an additional test subfolder, allowing separate configurations for test and production connections while using the same AS2 identifier (Partner Types | Aayu Technologies).

For example, if ALIBB is a test partner under the station alice, its folders will be:

  • as2gateway/alice/ALIBB/test/inbox

  • as2gateway/alice/ALIBB/test/outbox

  • as2gateway/alice/ALIBB/test/error

Sending Files via AS2

There are two modes of sending files.

  1. To send a single file as an AS2 message, simply upload the file to the respective outbox and AS2 Gateway will pick it up and queue it for delivery, within a maximum of 30 seconds.

       put <local path>/<filename> as2gateway/<station ID>/<partner ID>/outbox/
    
  2. To send multiple files in a single AS2 message, create a folder inside the outbox, and place all files into it.

    AS2 Gateway will process and enqueue the folder content, two minutes after the last file is uploaded.

       cd as2gateway/<station ID>/<partner ID>/outbox/
    
       mkdir <a unique folder name; say "20250101101035">
            
         cd 20250101101035/
            
         put <file 1>
            
         put <file 2>
            
         ...
            
         put <file n>
    
    

Receiving Files via AS2

Files received to an AS2 station will appear in the inbox folder

as2gateway/<AS2-Station-ID>/<AS2-Partner-ID>/inbox

The file saving path depends on the receiving trading station’s inbox folder structure configurations (AS2 Gateway - Creating an AS2 Station | Aayu Technologies).You can fetch the file using the SFTP get command.

Handling Failed Transfers

If a file fails to send, it will appear in the failed folder

as2gateway/<AS2-Station-ID>/<AS2-Partner-ID>/failed

AS2 Gateway

Fore more details, Refer : AS2 Gateway - SFTP Integration | Aayu Technologies

Conclusion

Integrating AS2 Gateway with SFTP ensures secure, efficient file exchanges, enhancing data security, compliance, and operational efficiency. It reduces manual intervention and streamlines data transfer, making AS2 Gateway a powerful solution for enterprise communication.


MFT gateway
AS2 Connection as a service for B2B EDI/ file transfer
Start Free Trial View Pricing