PHP Agent (HTTP)

PHP Agent lets you manage files on a web server via HTTP — without any SSH account or SSH daemon. The entire server-side logic lives in one file: sftp.php.

Typical use case: shared hosting where you have FTP/SFTP disabled or no shell access, but PHP is available.

Important — read before you do anything:
The sftp.php included in the plugin package has no password configured. If you upload it to your server before setting a password in the plugin, the server will reject every connection with HTTP 503. Always set the password in the plugin dialog first, save the session, then upload.

How it works — the big picture

  1. You choose a password for the connection.
  2. The plugin stores a salted SHA-256 hash of that password into your local sftp.php. The password itself is never written to any file.
  3. You upload that modified sftp.php to your web server.
  4. When you connect, the plugin signs every request (HMAC-SHA256) with a key derived from the password: the same salted hash that is stored in sftp.php. The password itself never leaves your computer. The server checks the signature, the time and a single-use nonce, and refuses any request whose operation, parameters or content were altered on the way.

This means: your password is in no file and on no network. The hash in sftp.php, however, is the key the server checks signatures with — whoever can read that file can send signed requests. Keep it readable by the web server only (permissions 600 or 640), and use a long random password: the hash is a single salted SHA-256, so a short or common password can be guessed from it offline.

Use HTTPS. Signing protects the password and the requests on plain HTTP too, but not your files: over http:// anyone on the network path sees every file and listing you transfer. HTTPS encrypts them.

Step-by-step deployment

Step 1 — Set up the connection in Total Commander

Open the plugin connection dialog (Net → Connect, or the Network Neighborhood panel). Fill in:

FieldWhat to enterExample
Connect to:Full HTTPS URL to sftp.php on your server (the file does not exist yet — enter where it will be)https://example.com/sftp.php
Transfer mode:Select PHP Agent (HTTP) from the dropdown—
Password:Choose any password — this will be your shared secret between TC and the serverMySecretPass123
Session name:Give the session a name for easy identificationMy Hosting
URL format: Always use https:// in production. Plain http:// is for local testing only — over HTTP the files and listings you transfer travel unencrypted.

Step 2 — Save the session

Click Save (or press F2 if available). At this point the plugin:

The local sftp.php that now contains your password hash is located at:

...\Total Commander\plugins\wfx\SFTPplug\sftp.php

This is the file you will upload. Do not use the original sftp.php from the download package — it has empty PSK fields.

Step 3 — Upload sftp.php to your server

Copy the file from the path above to your web server so that it is accessible at the URL you entered in Step 1.

Example: if you entered https://example.com/sftp.php, upload the file to the root of your web space as sftp.php.

You can upload it using any method: FTP, cPanel File Manager, your hosting control panel, or any other file manager.

File permissions on Linux servers: Set sftp.php to mode 644 (readable by web server, not world-writable).

Step 4 — Verify the endpoint

Before connecting, verify the script is reachable and correctly configured. Open this URL in your browser:

https://example.com/sftp.php?op=PROBE

Expected responses:

ResponseMeaning
HTTP 200 with JSON containing "ok":trueAll good — proceed to connect
HTTP 401 UnauthorizedScript is running but waiting for auth — this is also OK (plugin will authenticate)
HTTP 503 Service UnavailablePSK not configured — you uploaded the wrong file (without hash). Repeat from Step 2.
HTTP 404 Not FoundWrong URL or file not uploaded yet
PHP error pagePHP version too old (<7.4) or required extension disabled on server

Step 5 — Connect

Select your saved session in Total Commander and connect. The plugin probes the endpoint, confirms capabilities, and opens the remote file panel.

What is stored where — security summary

LocationWhat is storedIs the password exposed?
sftpplug.ini (on your PC)Password encrypted with Windows DPAPI (user-account bound)No — DPAPI ciphertext only
sftp.php (on server)AGENT_PSK_SALT (random) + AGENT_PSK_SHA256 = SHA-256(salt + password)No — one-way hash only. The hash is the signing key, though: protect the file like a password
Network trafficA signature per request (HMAC-SHA256, single-use nonce, 5-minute window) — never the passwordNo. Over plain HTTP the transferred files and listings themselves are readable
In short: No file and no request holds your password. The hash in sftp.php signs requests, so keep that file private to the web server. HTTPS keeps the transferred files private as well, and is required for anything beyond local testing.

URL formats

https://example.com/sftp.php
https://example.com/tools/sftp.php
https://example.com:8443/sftp.php
http://192.168.1.10/sftp.php         (local testing only — no encryption)

TAR Stream mode

When the TAR stream checkbox is enabled in the connection dialog, all directory downloads and batch file transfers are handled as a single TAR archive exchange instead of individual HTTP requests. This eliminates per-request overhead and is critical on shared hosting (OVH, home.pl) where thousands of individual GET/PUT requests would be extremely slow.

Batch Download (TAR_PACK)

When you copy multiple remote files or a remote directory to local, the plugin collects all file paths during the TC copy operation and sends a single POST ?op=TAR_PACK request with all paths listed in the body (one per line). The server-side sftp.php streams a ustar TAR archive of exactly those files directly to the response — without any temporary file or memory buffer. The plugin parses the TAR on the fly, creates local directories and files as each entry arrives, and shows a progress bar based on file count. GNU long-name entries (././@LongLink) are fully supported for paths over 99 characters.

Directory Download (TAR_STREAM)

When you copy an entire remote directory to local, the plugin sends one GET ?op=TAR_STREAM&path=... request. The server streams a ustar TAR of the entire directory tree. The plugin parses and extracts on the fly.

Upload (TAR_EXTRACT)

When you copy multiple local files or directories to a remote location, the plugin batches all of them into a single ustar TAR stream and sends one POST ?op=TAR_EXTRACT&path=... request. The server extracts the archive. Batching is transparent to Total Commander — files are queued during the copy operation and sent all at once when TC signals end-of-batch. The total archive size is sent as a proper 64-bit Content-Length header, so uploads of directories exceeding 4 GB work correctly.

Note: TAR mode requires a current version of sftp.php on the server (one that supports TAR_STREAM, TAR_EXTRACT, and TAR_PACK). Always upload the sftp.php from the plugin directory — not an older copy. Resume is not supported for TAR transfers; if interrupted, re-copy the whole set.

Upload method and chunk size

When PHP Agent or PHP Shell mode is active, the connection dialog shows two extra controls (replacing the encoding codepage and system dropdowns):

Capabilities

PHP Shell Console

If shell_exec is available on your server, you can use PHP Shell (HTTP) transfer mode for a pseudo-terminal experience:

Uses the same sftp.php file — no separate deployment needed.

The shell is not confined to the agent root. File operations stay inside the folder sftp.php lives in (AGENT_ROOT), but shell commands run as the web server user and reach everything that user can. Anyone holding the password gets that access. If you do not need the shell, open sftp.php and set const AGENT_ALLOW_SHELL = false; — the agent then refuses SHELL_EXEC and the password gives file access only.

Server requirements

PHP INI limits that affect uploads

The plugin reads these limits via PROBE and adjusts chunk size automatically.

Troubleshooting

ErrorCauseFix
HTTP 503Uploaded the raw sftp.php without PSK configuredSave session in plugin first, then re-upload the modified sftp.php from the plugin directory
HTTP 401Password in plugin does not match hash in sftp.phpRe-save the session with the correct password, re-upload sftp.php
HTTP 404sftp.php not at the URL you enteredVerify the URL and that the file was uploaded to the correct path
HTTP 500PHP error on serverCheck server PHP error log; verify PHP version ≥ 7.4 and required functions not disabled
Connection refused / timeoutServer unreachable or HTTPS certificate errorTest URL in browser; check SSL certificate validity
TAR batch download — 0 files receivedOld sftp.php without TAR_PACK support, or path mismatchUpload the current sftp.php from the plugin directory to the server
HTTP 504 on TAR download (OVH/home.pl)Old sftp.php that buffers TAR in php://temp before sendingUpload the current sftp.php — streaming version eliminates the timeout
TAR upload fails for large directories (>4 GB)Old plugin build — 32-bit integer overflow in Content-LengthUpdate the plugin to the current build

See also

Back to index