Default SFTP Port Setup and Configuration for Automated Agent Workspaces
Setting up and configuring a custom SFTP port helps minimize automated scan traffic and brute-force attempts on agent host servers. However, self-managed SFTP configurations create outbound firewall issues for agent runners and lack the version control needed for multi-agent environments. Fast.io resolves these issues by replacing SFTP with secure, persistent workspaces accessible via the Model Context Protocol.
The Role of the SFTP Port in Agent Workspaces
Developers deploying automated agent environments frequently struggle with file persistence and security when coordinating multiple models. When using a self-hosted server to coordinate agents such as Claude Code, Cursor, or custom Python frameworks, establishing a secure file transfer pathway is essential. The standard network protocol for this task is SFTP, which developers use to allow remote agents to upload source files, write logs, and retrieve datasets.
The SFTP port is the network port (defaulting to TCP port 22) through which secure shell (SSH) file transfer protocol connections are initiated and maintained. In this architecture, the client establishes an SSH connection first, and the SFTP subsystem is initiated over that single channel. Because all authentication, directory navigation, and file transfers travel through this single TCP port, the protocol is highly firewall-friendly compared to older protocols. For example, FTPS requires a passive data port range to negotiate file transfers, which often breaks network firewalls. Since the standard SSH port is open to the public internet, it faces continuous exposure. Automated botnets scan the public IPv4 space continuously, testing millions of SSH ports daily with brute-force credential lists. For automated agent workspaces that must remain online, leaving the SFTP daemon on its default port creates unnecessary log noise and presents a persistent security risk. Setting up a non-standard port helps reduce this noise, though it introduces other operational challenges.
To manage agent output securely without the complexity of traditional file transfer protocols, developers are transitioning to cloud-based environments. These environments can be configured through interfaces like Fast.io secure workspaces, which allow teams of humans and autonomous agents to collaborate on a shared filesystem.
Related guides
- Best API Gateways for AI AgentsAI agents make hundreds of LLM calls per task, and each call costs money, adds latency, and creates a failure point....
- 8 Best Webhook Platforms for AI Workflows (2026 Guide)Webhook platforms for AI workflows provide reliable event delivery, payload transformation, and retry logic to connect...
- Best APIs for Autonomous Agents: Essential ToolkitAutonomous agents need more than just intelligence; they need tools to interact with the world. While Large Language...
- How to Integrate the Fastio API with SvelteKitSvelteKit's server-side form actions and API routes make it a strong fit for integrating with the Fastio API. This...
- How to Handle Structured Output from AI AgentsGood AI agents do more than just chat. To use them in real software, they need to output structured data (like JSON or...
- How to Handle Fastio Webhook Delivery FailuresHandling Fastio webhook delivery failures requires implementing idempotent endpoints and resilient retry mechanisms to...
More on this subject: Agent Integrations and APIs (96 guides)
What Is the Security Impact of Changing the Default Port?
Understanding what is sftp port exposure helps teams evaluate the risk to their infrastructure. Leaving your SSH daemon on default port 22 means your authentication logs will be flooded with automated brute-force attempts. As documented in Teleport's analysis of SSH port security, an internet-facing server on port 22 absorbs continuous automated scanning, credential stuffing, and brute-force traffic from botnets that do nothing but probe port 22. Security logs show that port 22 is targeted by automated brute-force attacks millions of times daily. While strong public-key authentication protects against these attempts, the volume of authentication traffic consumes system memory, bloats log files, and complicates intrusion detection.
Obfuscating the SFTP port to a custom high port reduces unauthorized scan traffic by over 95%. This reduction is not a complete security solution, but it removes the server from low-effort automated scans. This allows security teams to focus on targeted intrusion attempts. However, moving to a non-standard port introduces firewall traversal challenges. Many corporate networks block all outbound connections except for standard ports like 80, 443, and sometimes 22. If your automated agents run inside a restricted environment, they may not be able to connect to a custom high port. This creates a trade-off between host server protection and client connectivity.
As detailed in EnterpriseDT's analysis of secure protocols, port 22 is the default port for SFTP, meaning it is the first point of attack for automated scripts. Moving to a custom port is a common practice, but it must be paired with public key authentication and rate limiting to be effective.
Steps to Change the SFTP Port in sshd_config
To change sftp port settings on your host server, you must edit the SSH daemon configuration file. Before making any changes, you must keep your active terminal window open. If a configuration error occurs during this process, closing your active session can lock you out of the server permanently. Keeping a backup session active allows you to revert changes if the service fails to restart.
First, open the SSH configuration file with administrative privileges:
sudo nano /etc/ssh/sshd_config
Locate the line specifying the port. By default, this line is commented out:
#Port 22
Uncomment the line and change the port value to a custom high port between 1024 and 65535. Ensure that the chosen port is not in use by another service on the system:
Port 2222
If you want the daemon to listen on both the standard port and your custom port during testing, add a second port directive on a new line:
Port 22
Port 2222
Next, find the Subsystem directive for SFTP. It typically looks like this:
Subsystem sftp /usr/lib/openssh/sftp-server
If you want to restrict users exclusively to SFTP access without allowing full shell execution, append a Match block to the end of the file:
Match Group sftp-only
ChrootDirectory %h
ForceCommand internal-sftp
AllowTcpForwarding no
X11Forwarding no
Before restarting the daemon, you must update your firewall configuration to allow traffic on the new port. If you are using the Uncomplicated Firewall (UFW) on Ubuntu, run:
sudo ufw allow 2222/tcp
sudo ufw reload
Save the file and verify the configuration syntax before restarting the daemon:
sudo sshd -t
If the test returns no errors, restart the SSH service to apply the new port configuration:
sudo systemctl restart ssh
Test the connection from a remote machine using the custom port parameter:
sftp -P 2222 username@your-server-ip
This procedure ensures your SSH daemon listens securely on the new port, but you must ensure your agents are updated with the new port number.
Persist developer agent files in secure workspaces
Provide your agents with shared workspaces accessible via the Model Context Protocol. Skip the firewall management and port configuration. Start your 14-day trial today.
Resolving Firewall Traversal and Agent Workspace Routing
While changing the sftp port reduces log noise on the host server, it complicates outbound access for automated agents operating in multi-tenant cloud runners or local developer environments. Many container hosting environments and enterprise firewalls restrict outbound traffic to standard ports like 80 and 443. When an agent attempts to write output files to an SFTP server listening on port 2222, the connection frequently fails at the firewall layer.
Developers can resolve this routing limitation using alternative architectures:
First, they can keep the default port 22 but implement restrictive host-based firewall rules. This configuration drops all incoming TCP packets unless they originate from the specific IP addresses of your agent runners. While secure, this method requires maintaining a static list of IP addresses, which is difficult when using dynamic cloud runners.
Second, they can deploy an SSH reverse proxy. This involves configuring a proxy on port 443 that forwards incoming SSH traffic to the internal SFTP daemon on the host. This bypasses outbound firewall blocks but requires additional proxy infrastructure and adds latency to file transfers.
Third, they can transition to cloud-native agent workspaces. Instead of maintaining local Linux host servers, managing user directories, and troubleshooting firewall rules, developers can use a cloud workspace platform to handle agent data persistence. Fast.io provides shared workspaces where files are automatically versioned, indexed, and made queryable. Agents interact with these workspaces using standard secure HTTPS requests.
For teams that require automated workspace operations across multiple external services, native features like Fast.io URL Import allow pulling files from Google Drive, OneDrive, Box, or Dropbox directly into workspaces without routing traffic through local servers.
Connecting Agents via the Model Context Protocol
In modern developer workflows, exposing files via SFTP is increasingly replaced by the Model Context Protocol. The Fast.io MCP server allows developer tools like Claude Code, Cursor, or Gemini to read, write, and search files inside secure workspaces without managing network ports or host daemons.
The Fast.io MCP server is remote, hosted at https://mcp.fast.io/mcp, and operates over Streamable HTTP. It also supports a legacy SSE transport. To configure an agent like Claude Code or Cursor to use this server, add the configuration details to your environment configuration block.
This protocol is fully supported by the Fast.io MCP server documentation, which outlines how agents can interact with workspaces using structured API actions. For developers running multiple developer tools, connecting via the MCP server is more reliable than managing individual SSH server instances.
For systems that authenticate by passing a token on each request, configure the server URL with your API key:
{
"mcpServers": {
"fastio": {
"url": "https://mcp.fast.io/mcp/key",
"headers": {
"Authorization": "Bearer YOUR_FASTIO_API_KEY"
}
}
}
}
This architecture provides several advantages over traditional SFTP setups:
- No Port Management. The connection is established over standard HTTPS port 443, eliminating firewall blocks and avoiding the need to change your server port.
- Built-in Workspace Intelligence. When Intelligence Mode is enabled on a Fast.io workspace, uploaded files are auto-indexed. Agents can perform hybrid search, combining full-text and semantic queries, directly through the MCP toolset.
- Granular Permissions. Instead of granting full directory access to an SSH user, you can set permissions at the organization, workspace, folder, or file level.
- Handoff and Ownership. Once an agent finishes writing code or generating documentation in a workspace, the agent can transfer ownership of the workspace to a human supervisor while maintaining admin access records.
- Coordination Rooms. In multi-agent environments, agents and humans can coordinate inside shared rooms. These rooms act as neutral ground where models from different vendors post messages, track presence, and hand off files. This prevents agents from overwriting each other's work and keeps the development history fully auditable.
By replacing self-managed SFTP servers with secure coordination rooms, developers can build multi-agent workflows that remain firewall-compliant and easy to monitor.
Frequently Asked Questions
What is the default port for SFTP?
The default SFTP port is TCP port 22. This is the same port used for standard SSH connections, as SFTP operates as a subsystem within the SSH protocol.
How do I change the default SFTP port?
You can change the default port by editing the SSH configuration file at `/etc/ssh/sshd_config` on the host server. Update the Port directive to your desired custom port number, verify the syntax with `sshd -t`, and restart the SSH service.
Is the SFTP port the same as the FTP port?
No. FTP typically uses port 21 for commands and a passive range of ports for data transfers. SFTP relies entirely on a single port (usually port 22) to handle authentication, commands, and data transfers securely.
Related Resources
Persist developer agent files in secure workspaces
Provide your agents with shared workspaces accessible via the Model Context Protocol. Skip the firewall management and port configuration. Start your 14-day trial today.