Git on ISPmanager hosting: deploying a site from a repository

Git is available in the Shell client. One command deploys the site, another updates it.

Public repository

cd ~/www/example.com
git clone https://github.com/USER/REPO.git .

The dot at the end clones right into the site folder. The folder must be empty: delete the placeholder index.html first. Updating the site:

cd ~/www/example.com
git pull
Cloning and git pull
Cloning and git pull

Private repository: an access key

A private repository needs a key. Create it in the Shell client and add it to the repository settings as a deploy key (read-only).

ssh-keygen -t ed25519 -N "" -C "deploy@example.com" -f ~/.ssh/deploy_key
cat ~/.ssh/deploy_key.pub

Copy the ssh-ed25519 ... line and paste it: GitHub — repository → Settings → Deploy keys → Add deploy key; GitLab — Settings → Repository → Deploy keys.

From the hosting, GitHub is reachable over SSH on port 443. Set this in ~/.ssh/config:

Host github.com
  HostName ssh.github.com
  Port 443
  User git
  IdentityFile ~/.ssh/deploy_key
The key and the connection settings
The key and the connection settings

Check: ssh -T git@github.com. Before the key is added to the repository the answer is Permission denied (publickey), after — a greeting with the repository name. Then:

cd ~/www/example.com
git clone git@github.com:USER/REPO.git .

Instead of a key you can clone over HTTPS with an access token: git clone https://TOKEN@github.com/USER/REPO.git .. The token is saved in .git/config — make it read-only and for this repository only.

What not to keep in the repository

  • .env, wp-config.php and other files with passwords — create them on the hosting.
  • vendor and node_modules — after git pull run composer install --no-scripts or npm install.
  • User uploads (for example wp-content/uploads).

If the site is served from the repository root, the .git folder is reachable from the internet with the whole code history. Close it in .htaccess with RedirectMatch 404 /\.git or keep the site in a public subfolder and set it as the website public directory.

Scheduled updates

To make the site pull changes itself, add a job in Cron, for example hourly: cd /var/www/LOGIN/data/www/example.com && git pull -q.

Questions and answers
Port 22 is closed; GitHub is reachable via ssh.github.com on port 443. Set it in ~/.ssh/config as shown in the guide.
Delete the placeholder files from the site folder, or clone into a subfolder and set it as the public directory.