top of page

What is SFTP (Secure File Transfer Protocol)?

Oct 24
13 min read
What is SFTP (Secure File Transfer Protocol)?

 

SFTP is a protocol for transferring and managing files through a protected SSH connection. Commonly called Secure File Transfer Protocol, its protocol name is SSH File Transfer Protocol. It supports operations such as listing directories, uploading, downloading and renaming files, while SSH provides encryption, integrity protection and authentication.

 

SFTP is a different protocol from FTP and FTPS. A normal SFTP session carries file operations through one SSH connection, commonly on TCP port 22, rather than opening FTP-style separate control and data connections. The server's actual port and supported authentication methods still need to be checked.

 

A protected connection is only part of a successful transfer. You also need to verify the server's identity, use an account with the right permissions and check that the finished file contains the intended data. Our original local test below shows why even a successful resumed download can produce the wrong file.

 

What does SFTP do?

 

SFTP lets a client work with files on a server within the account's permitted area. Typical uses include sending a dataset to another organisation, retrieving an export, uploading website files or automating an exchange between systems. Operations can include creating directories, checking file attributes, reading or writing file ranges, renaming files and deleting them where authorised.

 

The secure connection comes from SSH, or Secure Shell. SFTP uses SSH's transport and authentication mechanisms but requests a file-transfer subsystem instead of an interactive terminal. An administrator can provide SFTP access without granting a general-purpose shell.

 

SFTP does not automatically synchronise folders, maintain previous versions or create a backup. It can overwrite or delete a file when permissions allow. A successful upload also does not mean that a receiving application has imported, validated or published its contents.

 

How SFTP works over SSH

 

From a TCP connection to file operations

 

In a normal network session, the client first reaches the server's configured SSH port. The two sides negotiate compatible SSH algorithms and establish a protected transport, including a check of the server's identity. The user then authenticates using a method allowed by the service, such as a password, a public key or a configured combination of methods.

 

The client opens an SSH session channel and requests the SFTP subsystem. SFTP then negotiates its protocol version and supported extensions. If the SSH login is allowed but the subsystem is absent or prohibited, file transfer can still fail. Successful SSH authentication does not prove that SFTP is available.

 

For a file download, the client opens the remote file and receives a handle identifying it. READ requests specify that handle, a byte offset and the requested amount of data. Uploads use WRITE requests containing file data and offsets. Directory listings use their own directory operations. Responses carry data, handles, attributes or status information.

 

Request identifiers let a client match replies to outstanding requests. Several requests can be in progress together, which matters for performance over a path with significant round-trip time. These operations normally travel through the existing SSH connection; SFTP has no FTP active or passive mode to select.

 

SSH version and SFTP version are different

 

SSH protocol version 2 and SFTP protocol version 3 refer to different layers. Seeing SFTP version 3 in a log does not mean that the connection is using SSH version 1 or has necessarily fallen back to insecure encryption.

 

The OpenSSH specifications identify the version 3 file-transfer draft used by OpenSSH. The October 2001 document, draft-ietf-secsh-filexfer-02, is a historical Internet-Draft, not a completed RFC. Later revisions of that draft also expired. The SSH transport, authentication and connection protocols have their own RFCs, including RFCs 4253, 4252 and 4254, published in January 2006.

 

Implementations can add negotiated extensions. OpenSSH, for example, documents extensions for particular rename semantics and requesting a file flush. Support for a feature in one client-server pair does not establish support in every SFTP product. Use maintained software and its current security policy rather than copying algorithm lists from an old protocol document.

 

SFTP versus FTP, FTPS and SCP

 

Name

What protects the transfer?

Important distinction

SFTP

SSH transport, with server and user authentication

File operations normally share one SSH connection

Plain FTP

No built-in encryption for credentials or file contents

Separate control and data connections

FTPS

TLS added to FTP, with appropriate data-channel protection

Still uses FTP's control and data connection model

SCP

Depends on the tool and protocol selected

Modern OpenSSH scp uses SFTP by default; legacy SCP is a different protocol

 

The separate-connection behaviour of FTP explains why its firewall troubleshooting differs from SFTP. An FTP-only client cannot become an SFTP client merely by changing the port to 22. Select the exact protocol the service requires.

 

The SCP name needs care too. OpenSSH 9.0, released in April 2022, changed its scp command to use SFTP by default. A command named scp therefore does not, by itself, prove which file-transfer protocol is in use. Other tools and explicit compatibility options can behave differently.

 

Neither SFTP nor FTPS is automatically the right choice for every system. The required service, supported identity checks, account restrictions, automation and operational compatibility determine what works. “Secure FTP” on its own is an ambiguous description; ask whether the operator means SSH-based SFTP or TLS-based FTPS.

 

Three separate checks: server, account and file

 

Three separate SFTP checks: verify server host identity, confirm account path and operation permissions, and compare file contents with a trusted reference; encryption does not replace these checks

 

Verify the server's host key

 

The server's SSH host key identifies the remote host. A fingerprint is a compact representation of that key. On a first connection, compare it with a value supplied through a trusted independent route, such as the operator's authenticated management portal, or use an appropriately trusted host-certificate authority.

 

Blindly accepting an unfamiliar fingerprint creates trust in whatever server answered at that moment. Likewise, collecting a key with ssh-keyscan does not independently prove its authenticity. The OpenSSH keyscan documentation explicitly warns that collected keys need a suitable verification process.

 

For OpenSSH, the StrictHostKeyChecking setting controls how unknown or changed keys are handled. Setting it to yes requires the host identity to have been prepared and trusted already. The accept-new option can record a first key automatically and reject later changes, but that first automatic acceptance is not an independent identity check.

 

A changed-key warning can follow a legitimate rebuild or rotation, but it can also indicate that you reached the wrong system or that someone is impersonating it. Confirm the reason and replacement identity through a trusted route before changing the saved record. Deleting the warning and reconnecting is not verification.

 

Authenticate the user, then check permissions

 

The account's authentication key is different from the server's host key. With public-key authentication, the client proves possession of its private key using a signature; it does not send that private key to the server. The corresponding public key must be authorised for the intended account.

 

Protect private keys, use passphrases or suitable managed key protection where appropriate, and revoke credentials that are no longer required. A passphrase used to unlock a private key is not necessarily the account's server password. Automated jobs need a deliberate credential-management process rather than secrets embedded in shared scripts.

 

Authentication answers whether the service accepts the account identity. Authorisation determines what that account can do. Being able to list a directory does not imply permission to upload, rename or delete files there. A read-only account may be working exactly as intended when an upload is rejected.

 

Check the file itself

 

SSH protects data in transit between the participating endpoints. That does not establish that you selected the right source file, used a matching partial copy or wrote to the intended destination. It also does not supply encryption at rest, a retention policy or protection from an authorised account deleting the wrong file.

 

Verify the expected filename, size and contents where the consequence of an error matters. Treat server identity, account access and file correctness as separate questions rather than assuming one successful check settles all three.

 

Connecting and transferring safely

 

Before setting up a connection, obtain the service details through a trusted route. In a graphical client, choose SFTP explicitly and save only the settings needed for that service.

 

  • The hostname, configured port and exact protocol.

  • The trusted host-key fingerprint or host-certificate verification method.

  • The username and permitted authentication method.

  • The account's allowed paths and upload, rename or delete permissions.

  • Any source-address restrictions, quota and file-size limits.

  • A safe test directory and a recovery plan before replacing important files.

 

The following is an illustrative OpenSSH connection command for a service using port 2222. The example hostname and account are placeholders. It assumes that the correct host identity has already been verified and entered in the applicable known-hosts file; it is documentation-checked syntax, not a connection we made to a public server.

 

sftp -P 2222 -o StrictHostKeyChecking=yes transferuser@files.example.com

 

Once connected, pwd and ls help confirm the remote location. lcd changes the client's local directory; cd changes the remote directory. These different working directories are a common source of uploading or downloading the wrong file.

 

For an authorised test, the following interactive operations upload a small disposable file under a temporary name and download it for comparison. Replace the names with your own test files and check that a destination name will not overwrite anything important.

 

pwdlsput sample.bin sample.bin.partget sample.bin.part check.bin

 

Compare the returned copy with the source outside the SFTP session. The OpenSSH SFTP manual documents these commands, batch behaviour and resume options. In our local experiment, we executed the same operation types with synthetic files, including rename and resumed downloads.

 

For automation, check the client's exit status and record an outcome that another system can act on. OpenSSH batch mode normally stops when operations such as get, put or rename fail; command prefixes can suppress that behaviour, so do not assume every script will stop safely. A scheduled job that silently retries or suppresses errors can repeatedly deliver incomplete or unintended results.

 

Original test: a successful resume can still be wrong

 

On 24 October 2026, we tested the installed OpenSSH 9.6p1 client and SFTP server using the documented -D local mode. This connects the client directly to a local SFTP-server subprocess over pipes. It exercised actual SFTP version 3 file operations but did not use a TCP connection or SSH transport.

 

A temporary network SSH-server attempt had been blocked by the runtime before authentication. We therefore make no claim to have tested encryption, authentication or host-key verification. The local protocol test used disposable directories and a synthetic 1,048,576-byte file, consisting of every byte value from 0 to 255 repeated 4,096 times.

 

Local SFTP operation

Observed result

What it establishes

Upload, list and download

Exact bytes and matching SHA-256

This file round trip preserved the payload

Rename a temporary file to a new final name

Completed; contents unchanged

This tested rename worked on this local filesystem

Resume a matching partial download

Exact bytes and matching SHA-256

A known matching prefix plus the retrieved tail reconstructed the file

Resume a deliberately mismatched partial download

Exit status 0 and correct final size, but wrong bytes and hash

Transfer completion did not validate the existing prefix

Download a missing file

Nonzero exit status

The client reported the failed operation

Missing-file get followed by a put in batch mode

Batch stopped; later upload did not occur

The tested default batch sequence stopped on error

Download with one outstanding request and a 16 KiB buffer

Exact bytes and matching SHA-256

Those tested request settings preserved correctness

Upload requesting the fsync extension

Completed; exact bytes

The supported flush request completed, without testing crash recovery

 

For the resume comparison, each partial file started at 524,288 bytes, exactly half the source. One contained the correct prefix. In the other, we changed just its first byte. OpenSSH's reget operation continued each download from the existing length.

 

Both commands returned success and produced 1,048,576-byte files. Only the matching-prefix result equalled the source. The altered prefix remained in the other result, while the newly retrieved tail was correct. The full-file hash detected the difference that size and command completion missed.

 

This is not evidence of broken SSH encryption: the test did not use SSH, and the incorrect byte was deliberately present before resuming. It demonstrates an application-level precondition. Resume only when the partial copy belongs to the same unchanged source; restart when that cannot be established. The temporary files and subprocesses were removed or closed afterwards. No broadband throughput, internet path or storage-durability measurement is claimed.

 

SFTP infographic showing host identity verification, account authentication, protected SSH transport, file operations, matching partial files for resume, and verification before release

 

Finishing a transfer without losing the last good copy

 

Verify contents before release

 

For important files, compare a strong hash against a reference obtained through a trusted route, or compare the complete contents when both copies are available. The checksum guide explains the role of the reference value. A hash obtained from the same untrusted source as a file cannot independently establish who produced it.

 

Where the service supports it, upload under a temporary name, verify the result and then use its supported rename or release process. This can keep an application from treating a file as ready before the transfer has finished. The receiving application must actually honour that naming or release convention.

 

Do not assume every SFTP rename can replace an existing file atomically across all servers, filesystems and storage backends. OpenSSH's POSIX rename extension has specific semantics that differ from the base version 3 operation. Our test renamed a file to a new name; it did not prove a universal atomic-replacement guarantee.

 

Completion, flushing and processing are different outcomes

 

A successful transfer status reports the requested file operation. It does not prove survival after every power loss or confirm that a downstream application has processed the data. OpenSSH can request a file flush with its fsync extension when the server supports it. That is a specific request to the server, not a substitute for testing the storage system's recovery behaviour.

 

For a recurring exchange, record the intended version, verified transfer, release and receiving system's acceptance separately. Preserve a backup or recoverable previous version where replacement could cause harm. An encrypted connection alone does not provide that recovery path.

 

SFTP over a UK broadband connection

 

Connecting out is different from hosting at home

 

An SFTP client normally initiates an outbound connection to the remote SSH service. It does not require an FTP passive-port range or a server-initiated active data connection. This often makes the connection arrangement simpler, although routing, outbound filters and the remote service's restrictions still apply.

 

Hosting an SFTP server at home requires inbound reachability. CGNAT can prevent unsolicited inbound IPv4 connections from reaching the server, even if the home router has a forwarding rule. It does not automatically prevent a client behind CGNAT from connecting out to an accessible remote SFTP service.

 

An appropriate public IPv4 arrangement or suitable IPv6 connectivity may provide a hosting path, but addressing, routing, server support and firewall policy must all be checked. IPv6 does not mean unrestricted inbound access. Do not assume a provider's current products or terms without checking that specific service.

 

A dedicated account should receive only the file access it needs. In OpenSSH, an SFTP-only forced command and a directory restriction can form part of that design, but forwarding permissions need separate attention. A chroot directory also has strict ownership requirements; a writable upload area is usually a suitable child directory rather than a writable jail root. These are configuration principles, not a tested production-server recipe.

 

Why SFTP may not fill a fast connection

 

Actual performance depends on the complete path: available upstream or downstream capacity, round-trip time, TCP behaviour, packet loss, client request scheduling, server limits, CPU, encryption work and storage. Sending a backup from home uses upstream capacity; retrieving one uses downstream capacity. A headline package speed does not remove a bottleneck at the remote end.

 

SFTP request pipelining can matter independently of access-line capacity. Consider an idealised client using 32 KiB, or 32,768-byte, payload requests and an assumed 40 ms round-trip time. If it waits a full round trip for each batch of outstanding requests to complete, the request window gives the following simple model.

 

Outstanding requests

Payload in flight

Ideal payload MB/s

Ideal payload Mbit/s

1

32,768 bytes

0.8192

6.5536

64

2,097,152 bytes

52.4288

419.4304

 

The calculation is outstanding requests × payload bytes ÷ 0.040 seconds. MB/s here uses decimal millions of bytes; Mbit/s is eight times that value. It isolates a request-window constraint, excluding overhead and assuming the rest of the path can keep up. It is not a prediction of a particular server or a speed measured in our local test.

 

The current OpenSSH manual documents 64 concurrent requests and a 32 KiB buffer as defaults, but clients, versions and server limits differ. Increasing a limit cannot overcome every bottleneck and can consume more memory or exceed service limits. Our one-request test checked file correctness only; it did not measure a speed difference.

 

Many small files also add metadata operations, opens and closes. Compression may help compressible content but often adds work for already-compressed archives, images or video. Compare a permitted large-file transfer with the real workload and inspect both endpoints before changing request counts, compression or concurrency.

 

Troubleshooting SFTP by the stage that fails

 

  1. Check the hostname, SFTP protocol selection and configured port. A refusal or timeout before SSH negotiation points towards resolution, routing, filtering or a service that is not listening.

  2. Resolve server-identity warnings. Confirm the expected host key or certificate through a trusted route before accepting a new identity or replacing a stored key.

  3. If authentication fails, check the username, offered key or required method. A wrong key, unsupported algorithm or additional authentication requirement needs a different fix from a network timeout. Do not repeatedly guess credentials.

  4. If authentication succeeds but the SFTP subsystem fails, check that the server enables the subsystem for this account and that its restrictions allow it. Shell startup output can also disrupt some external subsystem arrangements.

  5. If listings work but one file operation fails, check its exact path, filename case, permissions, quota, storage space and account restrictions. A generic failure message does not identify one unique cause; use the server's relevant logs where authorised.

  6. For interrupted or resumed transfers, preserve the source and any last good copy. Establish that the partial file matches the current source, then verify the completed contents. Correct size alone is insufficient.

  7. For slow transfers, check direction, wired local connectivity, round-trip time, packet loss, request settings, storage and CPU at both ends. Change one relevant variable at a time and retain the comparison result.

 

Keep diagnostic logs free of private keys, passwords and unnecessary sensitive paths. A changed host key, permission error, unavailable subsystem and stalled transfer are different problems. Replacing all settings at once makes the cause harder to establish.

 

Key takeaway

 

SFTP provides file operations through SSH, normally without FTP's separate data connections. Use the correct protocol, verify the host, authenticate with appropriate credentials and test the operation the account actually needs. Then check the resulting file. Encryption protects the journey; it does not establish that you started with the right partial copy or delivered the intended version.

 

For related definitions, use the Techie Broadband terminology guide.

 

Frequently asked questions

 

What does SFTP stand for?

 

SFTP is commonly called Secure File Transfer Protocol. Its protocol name is SSH File Transfer Protocol, reflecting its normal use of SSH for protected file operations. It is a separate protocol from FTP and FTPS.

 

What port does SFTP use?

 

SFTP normally uses the server's SSH connection on TCP port 22. A service can use a different configured port. Select the SFTP protocol as well as the correct port; changing an FTP client's port does not make it speak SFTP.

 

Is SFTP the same as FTPS?

 

No. SFTP uses SSH, while FTPS adds TLS protection to FTP. FTPS retains FTP's separate control and data connections. SFTP normally carries its file operations through an SSH connection, so the clients and connection settings are not interchangeable.

 

Do I need a password to use SFTP?

 

That depends on the service's authentication policy. It may accept a password, public-key authentication or a configured combination of methods. A private-key passphrase and an account password serve different purposes. The server's host identity must also be verified.

 

Can SFTP resume an interrupted transfer?

 

Many clients support resuming, including OpenSSH with reget and reput. The partial file must match the same unchanged source. Our local SFTP test showed that resuming a mismatched prefix could return success and the correct final size while leaving the wrong file contents.

 

Does SFTP work behind CGNAT?

 

A client can normally connect out from behind CGNAT when outbound access and the remote service allow it. Hosting a reachable SFTP server is different: unsolicited inbound IPv4 may require an appropriate public addressing arrangement, or a suitable IPv6 path with correct firewall rules.

 
 
UK Techie Broadband Providers
bottom of page