Home / AWS

AWSTroubleshootingIntermediate

AWS Transfer Family SFTP failures: timeouts, Permission denied (publickey), empty home folders and failed uploads

Work out why partners can't connect to or upload through an AWS Transfer Family SFTP server, from endpoint and security group checks to keys, IAM roles, home directory mappings and SETSTAT errors.

Deepak Bhardwaj7 min read

Applies toAWS Transfer Family (SFTP, service-managed and custom identity providers), Amazon S3 storage, AWS CLI v2

A partner says "SFTP to your server is broken". With Transfer Family the failure is almost always one of four layers: the network path to the endpoint, authentication, the IAM role the session assumes, or the client doing something S3 can't do. The client error tells you which layer to start with.

Match the client error to a layer

Client symptom Layer Usual cause
Connection timed out Network Security group on the VPC endpoint, missing Elastic IP, wrong hostname, server OFFLINE
Connection refused / reset right away Network / server Server stopped or starting, a firewall in front of the client
Permission denied (publickey) Authentication Key not imported for that user, wrong user name, unsupported key type
Login works, ls shows nothing or Permission denied IAM role / home directory Role lacks s3:ListBucket, wrong home directory, logical mapping typo
Upload fails, file still appears in S3 Client behaviour Client sends SETSTAT (chmod/timestamps) after upload
Upload fails, nothing in S3 IAM / KMS Missing s3:PutObject or kms:GenerateDataKey
REMOTE HOST IDENTIFICATION HAS CHANGED Host key Server host key rotated or the hostname now points at a new server

Check 1: is the server up and reachable

SERVER=s-0123456789abcdef0

aws transfer describe-server --server-id $SERVER \
  --query 'Server.{State:State,Endpoint:EndpointType,IdP:IdentityProviderType,Protocols:Protocols,Logging:LoggingRole,HostKey:HostKeyFingerprint,Details:EndpointDetails}'

State must be ONLINE. If it shows OFFLINE, someone stopped it; if START_FAILED, check the endpoint configuration (subnets, Elastic IPs) before starting it again:

aws transfer start-server --server-id $SERVER

For PUBLIC endpoints the hostname is <server-id>.server.transfer.<region>.amazonaws.com. For VPC endpoints:

  • Internet-facing needs AddressAllocationIds (Elastic IPs) in EndpointDetails. Partners usually allow-list those IPs, so confirm they haven't changed.
  • The security group on the endpoint must allow TCP 22 from the partner's source range.
  • Internal endpoints are only reachable over VPN, Direct Connect or peering, so the client network needs a route.
aws ec2 describe-security-groups --group-ids sg-0abc1234 \
  --query 'SecurityGroups[].IpPermissions[?ToPort==`22`]'

From a test host, confirm the TCP handshake before you look at anything else:

nc -vz -w 5 s-0123456789abcdef0.server.transfer.eu-west-1.amazonaws.com 22
sftp -vvv -i partner_key partneruser@s-0123456789abcdef0.server.transfer.eu-west-1.amazonaws.com

-vvv shows whether the client got as far as key exchange, which proves the network is fine.

Check 2: turn on and read the server logs

Without a logging role you have no server-side evidence. Transfer Family writes to the log group /aws/transfer/<server-id>, with a log stream per user session.

aws logs filter-log-events --log-group-name /aws/transfer/$SERVER \
  --start-time $(($(date +%s) - 3600))000 \
  --filter-pattern '"partneruser"' \
  --query 'events[].message' --output text | tail -50

Look for authentication failures, ERRORS entries naming an S3 operation, and the source IP. If no events show up for the partner's IP at all, the connection never reached the server: go back to Check 1.

Tip

If LoggingRole is empty, add one now. The role needs to trust transfer.amazonaws.com and allow logs:CreateLogStream, logs:DescribeLogStreams and logs:PutLogEvents, or you can use the newer structured log destinations. Field names in log entries vary between logging formats, so check what your server actually writes.

Check 3: authentication

Service-managed users (SSH keys)

aws transfer describe-user --server-id $SERVER --user-name partneruser \
  --query 'User.{Role:Role,HomeType:HomeDirectoryType,Home:HomeDirectory,Mappings:HomeDirectoryMappings,Keys:SshPublicKeys[].SshPublicKeyBody,Policy:Policy}'

Compare the stored key with the partner's public key:

ssh-keygen -lf partner_key.pub      # fingerprint of what they say they use

Common mistakes:

  • The partner generated a new key pair and sent you the new public key, but they still connect with the old private key, or the other way round.
  • The key is in PuTTY .ppk or SSH2 format. Transfer Family expects OpenSSH format (ssh-rsa, ecdsa-sha2-nistp* or ssh-ed25519). Convert with ssh-keygen -i -f key_ssh2.pub or PuTTYgen.
  • The user name is case-sensitive and must match exactly.

Add the correct key without removing the old one until they confirm:

aws transfer import-ssh-public-key --server-id $SERVER --user-name partneruser \
  --ssh-public-key-body "$(cat partner_key.pub)"

Custom identity providers (Lambda or API Gateway)

Test the provider directly, which skips the network and client entirely:

aws transfer test-identity-provider --server-id $SERVER \
  --user-name partneruser --user-password 'P@ss...' \
  --server-protocol SFTP --source-ip 203.0.113.10

The response includes StatusCode, Message and Response. A good response returns a Role and either HomeDirectory or HomeDirectoryDetails. A missing Role, malformed JSON in HomeDirectoryDetails, or a Lambda timeout all fail the login. Check the Lambda's own CloudWatch logs next.

Warning

Don't paste real partner passwords into a shared terminal or ticket. Use a test user with the same configuration, or clear your shell history afterwards.

Security policy and old clients

Old clients and appliances may not support the ciphers in a newer security policy. The client log shows no matching key exchange method or no matching host key type.

aws transfer describe-server --server-id $SERVER --query 'Server.SecurityPolicyName'
aws transfer list-security-policies
aws transfer describe-security-policy --security-policy-name <policy-name> \
  --query 'SecurityPolicy.{Kex:SshKexs,Ciphers:SshCiphers,Macs:SshMacs}'

The right fix is for the partner to upgrade the client. Moving the server to a weaker policy affects every user, so treat it as a short-lived exception with a date to revert.

Check 4: the user's role and home directory

After login, every S3 call uses the user's IAM role (narrowed by the session policy, if one is set). The role must trust transfer.amazonaws.com, and it needs bucket-level and object-level permissions:

{
  "Version": "2012-10-17",
  "Statement": [
    { "Effect": "Allow", "Action": ["s3:ListBucket", "s3:GetBucketLocation"],
      "Resource": "arn:aws:s3:::partner-inbound" },
    { "Effect": "Allow",
      "Action": ["s3:PutObject", "s3:GetObject", "s3:DeleteObject", "s3:GetObjectVersion"],
      "Resource": "arn:aws:s3:::partner-inbound/*" }
  ]
}

Check the trust policy and whether it was changed recently:

ROLE=$(aws transfer describe-user --server-id $SERVER --user-name partneruser --query 'User.Role' --output text)
aws iam get-role --role-name ${ROLE##*/} --query 'Role.AssumeRolePolicyDocument'

If the bucket uses SSE-KMS with a customer managed key, the role also needs kms:Decrypt and kms:GenerateDataKey on that key, and the key policy must allow it. A missing KMS permission fails uploads even though listing works.

Home directory types

  • PATH: HomeDirectory is /bucket/prefix. If the prefix doesn't exist yet, the user sees an empty folder. That's normal in S3, but it often gets reported as "my files are gone".
  • LOGICAL: the user sees only what HomeDirectoryMappings exposes. One typo in Target and the session shows nothing.
aws transfer update-user --server-id $SERVER --user-name partneruser \
  --home-directory-type LOGICAL \
  --home-directory-mappings '[{"Entry":"/","Target":"/partner-inbound/acme"}]'

Caution

Changing a home directory or mapping for a live partner changes which S3 prefix their automated jobs write to. Agree the change with them first, or files land in a place your downstream pipeline doesn't read.

Check 5: uploads that "fail" but arrive

WinSCP and some other clients try to set permissions or timestamps (SFTP SETSTAT) after the upload. S3 can't do that, so the client reports an error even though the object is in the bucket. Partner jobs then retry and create duplicates. Tell the server to ignore SETSTAT:

aws transfer update-server --server-id $SERVER --protocol-details SetStatOption=ENABLE_NO_OP
aws transfer describe-server --server-id $SERVER --query 'Server.ProtocolDetails'

The client-side alternative is to turn off "preserve timestamp" and "set permissions" in the transfer settings.

Prevent it next time

  • Set a logging role on every server and alarm on authentication failures from known partner IPs.
  • Keep a test user with the same role and mapping pattern as partners, and run a scripted sftp -b upload and download after every change.
  • Manage users, roles and mappings in infrastructure as code so a typo shows up in review, not in production.
  • Publish the endpoint hostname, Elastic IPs, host key fingerprint and supported key types to partners, and give them notice before rotating any of them.
  • Use SetStatOption=ENABLE_NO_OP on S3-backed servers unless you have a reason not to.