Perhaps you've already asked yourself: "How do I go about publishing my WordPress website?" or "what's the best way to get my WordPress site online?". For any new developer or agency looking for a boost in their performance, you’d be slightly horrified by the onslaught of (outdated) opinions on Stack Overflow and Google dating all the way back to the inception of WordPress. Let me show you to a tried-and-tested deployment process to get your WordPress site from a local device to a server. Here we 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?
For starters, you won't need to drag and drop files anymore when you've got SSH set up. This leads to fewer errors and faster deployment times.
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 hostingplan for the free development of your WordPress projects: the FREE Dev Program. So if you want to practice SSH, you are on the right track.
Your BOX is the place where your website is hosted at RAIDBOXES but you won't be able to push your git-commits directly to it. This is a RAIDBOXES safety feature to ensure your BOX stays secure at all times. Instead, you'll need to use a third-party vendor to
git pull your repo into your BOX. I used GitHub for this tutorial. You're of course welcome to use a different service, the process itself will be very 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 establish a secure connection to GitHub and RAIDBOXES via an SSH connection. If you're not sure if you've 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 of all, we'll need to register the SSH key in the GUI (graphical user interface).
To do this, log in to the RAIDBOXES dashboard. Select the BOX you wish 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 save and return to your BOX dashboard.
In the SSH section, you'll find your credentials for the connection with RAIDBOXES via SSH. You'll need the following:
- 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'll now be prompted to enter your SSH passphrase. Once you've entered it, you'll see 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 is mentioned on the initial 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:
You can change the fundamentals of your WordPress site from this directory - by running
ls (list) in the console, you'll be shown your typical WordPress file tree:
Step 6: Initialize 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 from RAIDBOXES: Git is already installed on the server - as is WordPress CLI (WP-CLI). The only thing left to do now is to pull your GitHub repository into the RAIDBOXES WordPress file tree.
In order to keep your BOX secure, RAIDBOXES doesn't allow you to
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, go to the folder where your custom WordPress theme was created. Run the following in your terminal to initialize Git:
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
Great! Now your theme is online and ready to be pulled into your BOX.
Step 8: Upload 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 where you SSH connected into RAIDBOXES. Make sure you're in the directory where you initialized Git in your WordPress themes folder (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
... you'll be asked for your GitHub username and GitHub password - not your passphrase.
Step 9: Activate your Theme
Congratulations! The last step is to activate your WordPress theme. But why leave the comfort of your terminal? RAIDBOXES already has WordPress CLI installed. With a few lines of code, you save yourself the hassle 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 BOX dashboard. You'll find them under "Plugins & Themes"
If you're looking for a fast, secure, and more efficient way of developing and maintaining your WordPress sites, using Git and SSH is the way to go. Trust me, you'll soon be wondering how you managed to do it any other way!
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.
Thanks a lot for reading. I hope this article has helped you set up a proper workflow that will make your life easier when working with Custom Themes . Get started today and take full advantage of the RAIDBOXES dashboard!