Git without SSH

We've all been there: You need to quickly download something from a cheap shared hosting package (e.g., from IONOS). git pull You might want to run a program or use a database, but your hosting provider doesn't grant SSH access – or only in more expensive plans. Often, the only option left is the tedious process of manually uploading files via FTP, which makes deployments unnecessarily complicated and prone to errors.


One possible workaround is to mount the file system via sshfs. In theory, this sounds good: You mount the remote folder locally and work as if the files were on your own machine. To do this, you simply create a local directory and connect it to the server via the FTP/SSH user. The necessary commands to establish the connection and prepare Git for this folder look like this under Linux::

sudo apt-get install sshfs
mkdir /var/www/remote
cd /var/www/remote
sshfs username@your.host:/ -p 22 /var/www/remote
git config --global --add safe.directory /var/www/remote
git status
...
umount /var/www/remote

The problem: The performance is abysmal. Since Git struggles with commands like git status When performing thousands of small file operations, each requiring network access, one often waits minutes for even the simplest responses. Productive work is virtually impossible under these circumstances. Especially in projects with numerous dependencies, the terminal frequently freezes completely, forcing frustrated users to abandon the process.

Libraries like ftpsh exist for exactly this scenario. The library makes it possible to execute shell commands on a remote server that only offers (S)FTP and HTTP access. The trick: A PHP script is temporarily uploaded, which executes given commands and returns the output. This all happens in the background, but feels like a real shell.

The installation is quick and easy.:

mkdir ftpsh
cd ftpsh
wget -O ftpsh.sh https://raw.githubusercontent.com/vielhuber/ftpsh/main/ftpsh.sh
chmod +x ftpsh.sh

Then we lay a .env with the (S)FTP access data to:

HOST=your-server.com
PORT=22
USERNAME=your-username
PASSWORD=your-password
REMOTE_PATH="/"
WEB_URL="https://your-server.com"

Now we can execute any commands on the server, provided the tools are available remotely.:

ftpsh git status
ftpsh "mysqldump -h xxx --port 3306 -u xxx -p\"xxx\" --routines xxx" > dump.sql

The script uploads a worker in the background, runs the command locally on the server (where it is fast) and returns the result. This allows deployments, database dumps or Git operations to be automated efficiently, even on limited hosting environments. For example, it also works perfectly with syncdb for synchronizing databases.

Back