Publish from a private Github repository

It is very likely that you have plugins or themes for clients that are not public, or code that you use for one of your sites, which is on Github, and that you want to be deployed automatically.

This tutorial has been created on a VPS. You can create your own VPS from 3€/month.

In addition, you have the possibility to create your VPS with the WordPress image in one click.


The first thing we need is a repository on Github (or Gitlab).

This platform, in its section Settings includes a subsection called Deploy keys.

To add a new key we will need to give it a name and include your key.

So the first thing we have to do is go to the server where we are going to publish the repository content and create one.

We will enter by SSH in the web server and we will create a key. Please check the email account and put yours (it is recommended that it be the same as Github).

ssh-keygen -t rsa -b 4096 -C

First it will ask you where you want to leave your key (you can leave it in the folder that recommends you) or create a key for your specific plugin (let’s use /root/.ssh/mi-plugin.id_rsa)

Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):

It will then ask you for a password. In this case we will not put any. The server itself will be the password.

Enter passphrase (empty for no passphrase):
Enter same passphrase again:

This will create your key and save it, generating two files, the private key (id_rsa) and the public key (

Your identification has been saved in /root/.ssh/mi-plugin.id_rsa
Your public key has been saved in /root/.ssh/

Finally, a unique identifier will be generated:

The key fingerprint is:

You can check that both have been created. First we will look at the private key.

cat /root/.ssh/mi-plugin.id_rsa

And then the public key.

cat /root/.ssh/

This last code that appears on the screen is the one that we must include in Github. To do this, in the Add new Deploy key, we will put a name (for example, Plugin mi-plugin on server1).

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDMCNTqCtJEAQGnIgFlzeATKvAyezbbSOO0Di7NlRIpVsqm2zGoygnGlLIvLXzIs5IzAGwWLHJkdK8Pm5KvbgrToH2eq1BI8pfpFcI4HwiyjV871QzGcpJbtXnj6tRkmp2eJeFBVdZn8gFfIhlKW8n94yQLQb8OTEm57yiBxPpx97tsT/AAOM/q2KC+KACb1cve31dVAA6vkzOA47curc008iRslWLRdM7ybT/1gUWMmI/10329kYZscd0ZDFtdpfz99Z+Jz0BN/3O6OrUtYmMQKXOGoGTL10n/W9E8KjPzXB4u7tHzzCOIF1tqUD/vhn7CksT25/Pi82jX3aFJh55WuUObtBCd9oRwcF8Th1VZLaV3WEpzroZu1b883rdMDo1+O96lK17zz2oEGZ7OOmm03bnpSdY1/5js/WmdQ7LYnh9tSroSFGVighcrgwPmiJbLXAYWBB79eVqSjt0pX50igl3BnToQy0d5o2ZgrpnPP77RrTlwmCqQxw5H+uR2FH0nKvP8IWTcYHmAeWiajzPo0rhvy8HV2Hvi4seXmpDWax90KB1QdzsHNWIu0gH1OExY2ibcrlRFuaSsfAh0JH6UJSvFfjRt9LYFAb92gwJ/V/82x1GOVNjxLjgrTfxFL3k2trgwFxzioRf7mQveaRChR8IpO7tyc3/kH5mfv/ECRw==

It is important that we do not mark the option of Modo escritura, as it is not the target of this key, which is read-only.

The next thing we’ll do is add a configuration on the server.

vim ~/.ssh/config

And we will include something like that.

Host mi-plugin
  User git
  IdentityFile /root/.ssh/mi-plugin.id_rsa
  IdentitiesOnly yes

We will go to the folder of the website where we want to do the deploy.

cd /webs/

And we will launch the first synchronization.

git clone git@mi-plugin:wpsysadmin/mi-plugin.git carpeta-plugin

We must accept the first connection so that the trust between the servers is saved.

Once finished, we will see that there is a folder created, as we have previously called it.

cd carpeta-plugin/

There we will have the first download of the repository.

From here, we can update by running, in that folder, the following call.

git pull origin main

From here you can consider automating the download and synchronization as needed.

About this document

This document is regulated by the EUPL v1.2 license, published in WP SysAdmin and created by Javier Casares. Please, if you use this content in your website, your presentation or any material you distribute, remember to mention this site or its author, and having to put the material you create under EUPL license.