Verify SSH/SFTP Service
Make sure SSH is running on the Linux SFTP Server:
sudo systemctl status sshor:
sudo systemctl status sshdVerify port 22:
sudo ss -lntp | grep :22Test locally:
ssh localhostThe SSH service must work locally before configuring Cloudflare Tunnel.
Configure SFTP User Authentication
Use a dedicated SFTP user, for example:
your-sftp-userConfigure an authentication method for this user. The SFTP server may use either:
- SSH key authentication
- Password authentication
If SSH key authentication is used, add the client’s public SSH key to:
/home/your-sftp-user/.ssh/authorized_keysConfigure the required permissions:
chmod 700 /home/your-sftp-user/.ssh
chmod 600 /home/your-sftp-user/.ssh/authorized_keys
chown -R your-sftp-user:your-sftp-user /home/your-sftp-user/.sshThe authentication method must be working locally before testing the connection through Cloudflare Tunnel.
Install Cloudflare Tunnel Connector
After the Tunnel is created in Cloudflare, run the installation command generated by Cloudflare on the Linux SFTP Server.
Example:
sudo cloudflared service install <TUNNEL_TOKEN>Verify:
sudo systemctl status cloudflaredExpected status:
active (running)We recommend that you install and manage the Cloudflare Tunnel connector on your server so that you can maintain full control over access to your SFTP server.
You can refer to the Cloudflare Tunnel setup guide here: Cloudflare Tunnel Setup Guide
Verify Tunnel Connectivity
Check Cloudflare Tunnel logs:
journalctl -u cloudflared --no-pager -n 100Follow logs in real time:
journalctl -u cloudflared -fRestart the Tunnel if required:
sudo systemctl restart cloudflaredFirewall Requirement
Cloudflare Tunnel creates an outbound connection from the Linux SFTP Server to Cloudflare.
Therefore, public inbound access to:
TCP/22is not required for this connection flow.
The server-side architecture is:
The existing IP whitelist access remains the primary method, while Cloudflare Tunnel is used as a backup access option.
Start / Stop Tunnel
Start:
sudo systemctl start cloudflaredStop:
sudo systemctl stop cloudflaredRestart:
sudo systemctl restart cloudflaredEnable automatic startup:
sudo systemctl enable cloudflaredFinal Validation
- SSH/SFTP works on localhost:22.
- SFTP user is configured.
- SFTP user authentication is configured and works locally.
- cloudflared is installed and running.
- Cloudflare Tunnel status is healthy.
- Clients can connect through the Tunnel.
- Old VPN/IP whitelist access is removed only after successful validation.