Secure SFTP Setup Using AWS Transfer Family

In this article we will learn Secure SFTP Setup Using AWS Transfer Family. AWS Transfer Family offers fully managed support for Secure File Transfer Protocol (SFTP), enabling easy and secure file transfers directly into and out of Amazon S3. This article walks through setting up an SFTP server using AWS Transfer Family, covering everything from IAM configuration to user isolation, file transfers, and log verification.

Prerequisites

  • An active AWS Account.
  • IAM permissions to create S3 buckets, roles, and AWS Transfer Family resources.
  • FileZilla installed on local system.

Step #1:Create an Amazon S3 Bucket

This S3 bucket will serve as the storage location for all files transferred via your SFTP server. Go to Amazon S3 and click on Create bucket.

Secure SFTP Setup Using AWS Transfer Family 1

Select Bucket typeGeneral purpose. Enter the Bucket name you like my-sftp-transfer-bucket.

Secure SFTP Setup Using AWS Transfer Family 2

Keep default settings as it is and click on Create bucket.

Secure SFTP Setup Using AWS Transfer Family 3

As you can see our my-sftp-transfer-bucket is created successfully. Now go inside the bucket.

Secure SFTP Setup Using AWS Transfer Family 4

Click on Create folder to create a folder in a bucket.

Secure SFTP Setup Using AWS Transfer Family 5

Give the Folder name like Public Folder and click on Create folder.

Secure SFTP Setup Using AWS Transfer Family 6

You can see our folder is created. Follow the same procedure to create another folder.

Secure SFTP Setup Using AWS Transfer Family 7

Enter the Folder name like Restricted Folder and click on Create folder.

Secure SFTP Setup Using AWS Transfer Family 8

Now both of our folders are created.

Secure SFTP Setup Using AWS Transfer Family 9

Step #2:Create an IAM Role for AWS Transfer Family

This IAM role is crucial. It allows the AWS Transfer Family service to access your S3 bucket on behalf of the connecting SFTP user.

Navigate to IAM. And Go to Roles.

Secure SFTP Setup Using AWS Transfer Family 10

Click on Create role.

Secure SFTP Setup Using AWS Transfer Family 11

In Select trusted entity choose AWS service. Under Use case, find and select Transfer as a Service or use case. Click Next.

Secure SFTP Setup Using AWS Transfer Family 12

Search AmazonS3FullAccess and add it to policy. Click Next.

Secure SFTP Setup Using AWS Transfer Family 13

For Role name, enter AWS_Transfer_S3_Access_Role. (Optional) Add a description. Click Create role.

Secure SFTP Setup Using AWS Transfer Family 14

Now our role is created. You can see it below.

Secure SFTP Setup Using AWS Transfer Family 15

Step #3:Create the SFTP-Enabled Server in AWS Transfer Family

This creates the actual SFTP endpoint that your users will connect to. Navigate to AWS Transfer Family in the AWS Management Console.Click Create server.

Secure SFTP Setup Using AWS Transfer Family 16

Choose protocols:

  • Select SFTP.
  • Click Next.
Secure SFTP Setup Using AWS Transfer Family 17

Choose an identity provider:

  • Select Service managed. (This means AWS Transfer Family will store your user identities and SSH keys directly).
  • Click Next.
Secure SFTP Setup Using AWS Transfer Family 18

Choose an endpoint:

  • Select Publicly accessible.
  • Click Next.
Secure SFTP Setup Using AWS Transfer Family 19

Choose a domain:

  • Select Amazon S3.
  • Click Next.
Secure SFTP Setup Using AWS Transfer Family 20

Configure additional details:

  • Under CloudWatch logging, choose “Create a new role” or “Select an existing role” and allow it to auto-generate a log group. (This is highly recommended for monitoring). We have choosen Create a new role.
  • You can leave other options as default for this setup.
  • Click Next.
Secure SFTP Setup Using AWS Transfer Family 21

Review and create:

  • Review all your selections.
  • Click Create server.
Secure SFTP Setup Using AWS Transfer Family 22
Secure SFTP Setup Using AWS Transfer Family 23

The server will take a few minutes to provision and show “Online“.

Secure SFTP Setup Using AWS Transfer Family 24

Step #4:Generate SSH Key Pair

If you don’t already have an SSH key pair, you need to generate one. This key pair is used for secure authentication to the SFTP server. You can use Powershell or VS Code terminal.

If you don’t have aws cli configured then configure it by running following command.

  • AWS Access Key ID: Your_Access_key
  • AWS Secret Access Key: Your_Secret_Key
  • Default region name: Your_AWS_Region
  • Default output format: json
aws configure
Secure SFTP Setup Using AWS Transfer Family 25

Verify if its configured or not.

aws sts get-caller-identity
Secure SFTP Setup Using AWS Transfer Family 26

Create the .ssh directory in your user profile if it doesn’t exist

Navigate to C:\Users\YourWindowsUsername\ (replace YourWindowsUsername with your actual username, e.g., Dell). Create a new folder named .ssh inside this directory.

mkdir .ssh
Secure SFTP Setup Using AWS Transfer Family 27

Generate the key pair. Press Enter for the passphrase twice

ssh-keygen -t rsa -b 2048 -f C:\Users\YourWindowsUsername\.ssh\sftp_transfer_key
Secure SFTP Setup Using AWS Transfer Family 28

You will find two files created:

  • C:\Users\YourWindowsUsername\.ssh\sftp_transfer_key (Your private key – keep this secret!)
  • C:\Users\YourWindowsUsername\.ssh\sftp_transfer_key.pub (Your public key)

Step #5:Add a User to the SFTP Server

This step creates the SFTP user login associated with your S3 bucket and SSH key.

In the AWS Transfer Family console, select your SFTP server.

Secure SFTP Setup Using AWS Transfer Family 29

Click Add user.

Secure SFTP Setup Using AWS Transfer Family 30

User configuration:

  • Username: Enter a desired username (e.g., devopshint).
  • Role: Select AWS_Transfer_S3_Access_Role (the IAM role you created in Step 2).
  • Home directory:
    • Select your S3 bucket: my-sftp-transfer-bucket.
    • In the “Home folder” text box, type the path to the folder you want to restrict the user to: /Restricted Folder (assuming you created this folder in S3).
  • Restricted: Crucially, check the “Restricted” checkbox. This ensures the user cannot navigate outside Restricted Folder.
Secure SFTP Setup Using AWS Transfer Family 31

Open your public key file using following command.

Get-Content C:\Users\YourWindowsUsername\.ssh\sftp_transfer_key.pub
Secure SFTP Setup Using AWS Transfer Family 32

Copy the entire content of the public key string. Paste it into the “Paste the contents of SSH public key” text area. Click Add.

Secure SFTP Setup Using AWS Transfer Family 33

Step #6:Connect and Test File Transfers

Get Server Endpoint:

  • In the AWS Transfer Family console, select your SFTP server.
  • Copy the Endpoint URL
Secure SFTP Setup Using AWS Transfer Family 34

Open the terminal and run the following command. Type yes when prompted about the host’s authenticity. You should see the sftp> prompt upon successful connection.

sftp -i C:\Users\YourWindowsUsername\.ssh\sftp_transfer_key devopshint@YOUR_SFTP_ENDPOINT
Secure SFTP Setup Using AWS Transfer Family 35

Create a dummy file locally (e.g., test_upload.txt in C:\Users\YourWindowsUsername\)

Secure SFTP Setup Using AWS Transfer Family 36

Upload it using following command. And See your uploaded file using ls command.

put C:\Users\YourWindowsUsername\test_upload.txt
ls
Secure SFTP Setup Using AWS Transfer Family 37

Now lets try using FileZilla. Connect with FileZilla

Secure SFTP Setup Using AWS Transfer Family 38

Open FileZilla. Go to File > Site Manager.

Secure SFTP Setup Using AWS Transfer Family 39

Click New site.

Secure SFTP Setup Using AWS Transfer Family 40

You can change site name e.g. AWS SFTP Transfer.

  • Protocol: SFTP – SSH File Transfer Protocol.
  • Host: Your server endpoint.
  • Port: 22.
  • Logon Type: Key file.
  • User: devopshint.
  • Key file: Browse to C:\Users\YourWindowsUsername\.ssh\sftp_transfer_key (your private key). Click Connect.
Secure SFTP Setup Using AWS Transfer Family 41
Secure SFTP Setup Using AWS Transfer Family 42

You should see test_upload.txt in the remote pane. Drag and drop files from Local site to Remote site to test transfers.

Secure SFTP Setup Using AWS Transfer Family 43

You can verify that files are transferred to S3 Bucket. Go to S3 bucket > Restricted Folder.

Secure SFTP Setup Using AWS Transfer Family 44

Step #7:Verify Access Restriction

This is crucial to ensure your security settings are working.

From the sftp> prompt, try to navigate to the root directory or parent directory.

cd ..
ls
cd /
ls

the ls command should still only show the contents of Restricted Folder/ (e.g., test_upload.txt), indicating you cannot escape the confined home directory.

Secure SFTP Setup Using AWS Transfer Family 45

Step #8:Monitor Logs in CloudWatch

AWS Transfer Family integrates seamlessly with CloudWatch Logs, providing valuable insights into your SFTP server’s activity.

Navigate to CloudWatch in the AWS Management Console. In the left navigation pane, click Log groups under “Logs”.

Secure SFTP Setup Using AWS Transfer Family 46

Look for a log group starting with /aws/transfer/s-. This is the auto-generated log group for your SFTP server (the s- ID matches your Transfer Family server ID). Click on the log group name.

Secure SFTP Setup Using AWS Transfer Family 47

You will see one or more Log streams. Click on the latest log stream to view recent log events.

Secure SFTP Setup Using AWS Transfer Family 48

You’ll see entries for successful SSH authentication. File transfer operations (PUT, GET, DELETE). Connection attempts. Any errors or warnings related to your SFTP server.

Secure SFTP Setup Using AWS Transfer Family 49

Conclusion:

You have now successfully set up a secure and fully managed SFTP server using AWS Transfer Family. By leveraging this service, you’ve avoided the complexities of managing server infrastructure, benefiting from AWS’s scalability, reliability, and security features. Files are securely transferred directly into your Amazon S3 bucket, user access is precisely controlled and restricted to specific folders, and you can monitor all activity through CloudWatch Logs. This provides a robust and efficient solution for your file transfer needs.

Related Articles:

Send alerts to Microsoft Teams Using Elastic Stack

Reference:

AWS Official Page

Prasad Hole

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Share via
Copy link
Powered by Social Snap