Maybe you've asked yourself: "How do I publish my WordPress website?" or "What's the best way to get my WordPress website online?". As a budding developer - or as an agency looking to boost its performance - you would surely be horrified by the flood of (outdated) search results on Stack Overflow and Google around the topic of WordPress development. So in this post, I'm going to introduce you to a proven deployment process for getting your WordPress website from a local device to a server. Let's go with SSH!
What is SSH?
SSH (short for "Secure Shell") is a method of connecting to a system or server using the command line interface (CLI). Simply put, with SSH you don't have to waste time jumping around different user interfaces to transfer your data.
And what's so great about SSH?
Who is SSH for?
SSH can be used by development teams of any level and size. SSH is a very secure and fast way to edit your project and publish changes. If you tend to work on larger projects, you'll see a massive increase in efficiency when it comes to your workflow.
When used with Git, for example, you can put all your work in one repository and pull it to your server where you can work on your project as a team, without having to move files back and forth between you.
Why use SSH at all?
The reasons why people use SSH varies depending on the use case. But SSH is mainly used for these reasons:
- It's secure
- It's fast
- It can be automated!
And if those reasons weren't enough for you: you can also link SSH to Git's version control system. It's really easy if you need to roll back your development because of a bug or broken feature: you can do a rollback directly from your GitHub repository.
Using SSH as a junior developer?
When you start looking over this system for the first time, it might seem rather daunting. But there's no need to worry, I'm going to walk you through all the steps in this tutorial! We'll also cover the benefits of getting some valuable hands-on experience with the terminal, which is now an industry standard.
Why would an agency use SSH?
In addition to the timesaving benefits and version control mentioned above, SSH also lets you securely log in to your server from any device you have your SSH key installed on.
Not being tethered to one device means location freedom.
First steps with SSH
Raidboxes offers you a WordPress hosting plan for the free development of your WordPress projects. So if you want to practice SSH, you are on the right track.
Your Raidboxes Box is where you will host your WordPress website. However, you will not be able to push your Git commits directly. This is a security feature of Raidboxes that ensures your Box remains secure. Instead, you will need to use a third party provider to push your repo with
git pull into your Box . I used GitHub for this tutorial. Of course, you can also use another service - the process is quite similar.
This is what the process looks like:
If you already ...
- installed Git on your device,
- generated SSH keys,
- added your public SSH key to GitHub
then jump directly to step 4: Set up your SSH key in Raidboxes .
Step 1: Check if you have Git installed
You can check if Git is installed on the device you're using by opening your command-line tool (Windows) or terminal (Mac) and typing the following command:
If you see a version number, it means Git is installed on your device.
If you get an error message, you can install Git here. (You may need to update Git if you are using an older version).
Step 2: Set up your SSH keys
Check if there are existing SSH keys:
SSH keys are required to connect securely to GitHub and Raidboxes via an SSH connection. If you are not sure whether you have already generated SSH keys, you can usually find them this way:
- open Git Bash,
- Enter the following command:
ls -al ~/.ssh
If you already have SSH keys, you'll be presented with an output showing their names:
SSH keys can usually be found in the root directory of your users' devices. Check the directory:
C:\Users\<YOUR USER NAME>\.ssh
For more details on SSH keys, check out the official GitHub docs.
Generate new SSH keys:
There are several ways to create SSH keys. I recommend you to follow the documentation on GitHub Docs - there are instructions for Windows, Mac and Linux.
Step 3: Add your SSH key to GitHub
As a prerequisite to pushing your local development to GitHub, you need to add your SSH key to GitHub. To do so, follow the official GitHub documentation.
You can test whether you've set up the SSH key correctly by:
Step 4: Set up your SSH key in Raidboxes
Raidboxes allows you to connect to your server via an SSH connection. First you have to register the SSH key in the GUI (graphical user interface).
To do this, log into Raidboxes Dashboard . Select the Box you want to connect to via SSH:
Go to Settings > SSH:
Enable SSH by moving the slider to "on". Then click on your SSH preferences:
Have your SSH key ready (see step 2). Raidboxes requires you to enter your public SSH key.
Go to the directory on your local computer that contains your SSH keys:
Open the file
id_rsa.pub. Copy the entire contents of the file, including the 'ssh-rsa' at the beginning, and paste it into the SSH field as shown below:
Click on Save and return to the Dashboard of your Box .
In the SSH section you will find your access data for connecting to Raidboxes via SSH. You need the following access data:
- Host details
- SSH passphrase that you created for your SSH key (see step 2)
Open Git Bash (Windows) or Terminal (Mac). The command for connecting via SSH is:
An example with my dummy account would be:
You will now be asked to enter your SSH passphrase. Enter it - and welcome to your Raidboxes Box file tree!
IF you receive a warning message that the connection is unknown (it is the first connection), you can proceed as follows:
- Enter yes
- exit Git Bash,
- open Git Bash again
- re-enter your SSH details
Step 5: The Raidboxes directory structure
As mentioned in the welcome screen of the SSH connection to your Raidboxes Box , your pre-installed WordPress directory is located in
/home/wp/disk/wordpress. Your current working directory when you first connect via SSH is
In this directory, you don't have the appropriate permissions to init Git and
git pull your project here and you wouldn't want to do it either.
Go to your work folder:
From this directory you can change the basics of your WordPress website: If you
ls (list) in the console, you'll be shown your typical WordPress file tree:
Step 6: Initialise Git in Raidboxes
Change the directories in
wp-content/themes and create a directory. This is where you'll be initializing Git from and where you'll be pulling your locally developed theme from GitHub to.
mkdir <your theme name>
cd <your theme name>
Another cool feature of Raidboxes: Git is already installed on the server - as is WordPress CLI (WP-CLI). The last thing to do is to pull your GitHub repository into the Raidboxes WordPress file tree.
However, to keep your Box safe, Raidboxes does not allow you to do this,
git push directly from your local device into your git repo. Instead, you pull it from a service like GitHub.
(If you have already pushed your local development project to GitHub, please proceed to step 8).
Step 7: Upload your local Theme to GitHub
From your local device, navigate to the folder where your custom WordPress theme was created. Then initialise Git by running it in your terminal:
Create your repo on GitHub and add it as a remote to your custom development. For instructions on creating a GitHub repository, please read this documentation.
When you create a repo, you can choose between public and private. It's best to choose private for commissioned work. Note that this will prompt you to add your GitHub username and password (not your SSH passphrase) if you want to
git push ,
git pull from that repo.
Add your GitHub repo as a remote to use the
git push command:
git remote add <the alias you choose for the remote> <the remotes address>
Like in this example:
git remote add gitHub
Add your files, transfer them, and push them to your remote repository:
git add *
git commit -m '<your commit note>'
git push -u <the alias you gave your remote> <the name of the branch your working on>
(If you're not sure what the name of your remote is, run the command
git remote -v . This will show you all the names of the remote repositories).
$ git push -u gitHub master
Fantastic! Now your themeis online and ready to be plopped into your Box .
Step 8: Load your theme in Raidboxes
Just like adding your GitHub repository as a remote repository to push your own theme into GitHub, we're now going to add GitHub as a remote and pull that theme from the GitHub repository.
Open the Git Bash terminal in which you have connected SSH to Raidboxes . Make sure you are in the directory of your WordPress theme folder where you initialised Git (see step 6).
Now you'll add your GitHub repo as a remote.
You'll find the remote address to be added in GitHub:
Add the remote:
git remote add <choose an alias name> <the address of your github ssh repo>
git remote add gitHub https://github.com/XXXXXX/customWordpressTheme.git
Now pull the repo from GitHub:
Please note: Branch is most likely called master here. Unless you changed it or are working in a different branch on GitHub.
git pull <alias name> <branch>
git pull gitHub master
Step 9: Activate your Theme
Congratulations! The last step is to activate your WordPress theme . But why leave the terminal for this? Raidboxes already has WordPress CLI installed. With a few lines of code, you can save yourself the trouble of clicking around in the WordPress UI.
Simply run this command in the terminal:
wp theme activate <your theme name>
For a complete overview of the commands you can use with WP-CLI , please refer to the official documentation of WordPress .
If you prefer the UI, you can access all your themes from your Raidboxes Dashboard . You can find them under the navigation point Plugins & Themes:
Conclusion on SSH and WordPress Development
If you're looking for a fast, secure and more efficient way to develop and maintain your WordPress website, using Git and SSH is the way to go. Believe me, you'll soon wonder how you ever managed with any other workflow!
Everyone works at their own pace and has individual preferences when it comes to the right workflow. I highly recommend that you give SSH a chance and follow the steps described in this article. Who knows, maybe you'll be an instant convert and never want to go back to a different workflow.
Thank you for reading. I hope this article has helped you to set up a suitable workflow that will make your life easier when working with custom themes. Get started today and take full advantage of the Raidboxes dashboard!