SSH Commands Through Zapier
Sometimes file operations aren't enough. You need to restart a service, run a script, compress files, or check disk space. PushFTP's Run SSH Command action lets you execute shell commands on your remote server directly from a Zapier workflow.
The command runs over SSH through PushFTP's fixed IP address. Same IP your server already has whitelisted for file transfers — no additional firewall rules needed.
What You Need
- A PushFTP account with an SFTP connection (sign up free)
- PushFTP's static IP whitelisted on your server for SSH (port 22)
- A Zapier account
- Shell access on the remote server (the SFTP user must be allowed to execute commands)
Step 1: Verify SSH Access
Not all SFTP accounts allow command execution. Some servers restrict users to SFTP-only mode (no shell). Check with your server admin or test in PushFTP first.
Your connection must be of type SFTP — FTP and S3 connections don't support SSH commands (those protocols don't have a shell concept).
Step 2: Add the Run SSH Command Action
In your Zap:
- App: PushFTP
- Event: Run SSH Command
- Account: Your PushFTP account
Configure:
Connection: My SFTP Server
Command: ls -la /uploads/
The action returns the command's stdout output as text, which you can use in subsequent Zap steps.
Step 3: Test It
Start simple. Run whoami or pwd to verify the connection and user context:
Command: whoami
Expected output: your SFTP username.
Then try something more useful:
Command: df -h /uploads
This shows disk usage — helpful for monitoring. Check the getting started guide for connection setup if you need help.
Practical SSH Command Workflows
Post-Upload Script Execution
Upload a file, then run a script that processes it:
Trigger: PushFTP → New File Detected (/incoming/)
Action 1: PushFTP → Run SSH Command
Command: /opt/scripts/process-upload.sh {{filename}}
The script could parse a CSV, generate a report, update a database — whatever your server-side logic needs.
Compress Files Before Download
Zip files on the server, then download the archive:
Trigger: Schedule → Every Friday at 5pm
Action 1: PushFTP → Run SSH Command
Command: cd /reports/weekly && tar -czf archive-$(date +%Y%m%d).tar.gz *.csv
Action 2: PushFTP → Download File
Path: /reports/weekly/archive-{{date}}.tar.gz
Action 3: Gmail → Send Email with attachment
Disk Space Monitoring
Trigger: Schedule → Every Day at 8am
Action 1: PushFTP → Run SSH Command
Command: df -h / | tail -1 | awk '{print $5}'
Action 2: Code by Zapier
const usage = parseInt(inputData.output);
return { usage, alert: usage > 80 };
Action 3: Filter → Only continue if alert = true
Action 4: Gmail → Send Email
Subject: ⚠️ Server disk usage at {{usage}}%
Restart a Service
Trigger: Webhooks → POST from monitoring system
Action: PushFTP → Run SSH Command
Command: sudo systemctl restart my-app
Note: sudo commands only work if the SFTP user has passwordless sudo configured for that command.
Database Backup
Trigger: Schedule → Every Night at 2am
Action 1: PushFTP → Run SSH Command
Command: pg_dump mydb | gzip > /backups/mydb-$(date +%Y%m%d).sql.gz
Action 2: PushFTP → Download File
Path: /backups/mydb-{{date}}.sql.gz
Clean Up Old Files
Trigger: Schedule → Every Sunday
Action: PushFTP → Run SSH Command
Command: find /tmp/uploads -type f -mtime +30 -delete
Delete files older than 30 days. More precise than trying to loop through List Files results with individual Delete File actions. Check the delete guide for the action-based approach.
Using Command Output in Your Zap
The SSH command's stdout is available as a field in subsequent steps. Common patterns:
Parse as number:
Command: wc -l < /data/records.csv
Output: 1547
→ Use in Zapier as a number field
Parse as JSON:
Command: cat /config/status.json
Output: {"status":"running","uptime":86400}
→ Parse in a Code step with JSON.parse()
Use as a condition:
Command: test -f /uploads/ready.flag && echo "yes" || echo "no"
Output: yes
→ Filter: Only continue if output = "yes"
Security Considerations
SSH command execution is powerful — treat it carefully:
- Limit the SFTP user's permissions — don't use root for PushFTP connections
- Use specific commands, not interactive shells — each action runs one command
- Avoid putting secrets in commands — use environment variables or config files on the server
- Audit the command log — PushFTP logs all commands in your transfer history (7-90 days depending on plan)
- Test commands manually first — SSH into the server and run the command yourself before automating it
Command Limitations
- No interactivity — the command runs and returns output. No prompts, no stdin input
- Timeout — long-running commands may time out. Keep commands under 30 seconds
- Single command — each action runs one command string. Use
&∨to chain commands, or call a script - SFTP connections only — FTP and S3 connections don't support SSH commands
SSH commands give your Zapier workflows the full power of the command line. Restart services, run scripts, check disk space — anything you'd do in a terminal, triggered automatically through a secure fixed-IP connection.
FAQ
Can I run sudo commands?
Only if the SFTP user has passwordless sudo configured for the specific command. PushFTP can't provide passwords interactively. Set up /etc/sudoers entries on your server for the commands you need.
What happens if the command fails?
The action fails in Zapier with the stderr output as the error message. You can set up error handling in Zapier (try/catch paths) or use PushFTP's Transfer Failed trigger to catch failures.
Is there a command length limit?
There's no strict limit from PushFTP, but extremely long command strings may cause issues. For complex logic, write a script on the server and call it: /opt/scripts/my-workflow.sh
Can I run commands on multiple servers?
Yes — one command per action step, one connection per command. If you need to run commands on three servers, add three Run SSH Command steps with different connections. Each goes through PushFTP's fixed IP.
Beyond File Transfers
SSH command execution extends PushFTP beyond file operations. It turns your Zaps into remote administration tools — deploy code, manage services, run scripts, monitor systems. Combined with PushFTP's file actions and the Zapier integration, you can automate entire server workflows from a single platform.