Tutorials UPDATED: 30 June 2023

How to Use SFTP To Manage Files on WordPress

Tassos Antoniou

12 min read
How to use SFTP to manage WordPress files

If you’re a developer, you’ll no doubt be very familiar with using SFTP. For the rest of us who manage WordPress websites on occasion however, the mere mention of using SFTP to make a change to our WordPress website might be enough to fill you with a sense of trepidation! Fear not. In this article we’ll be looking at how to use SFTP to manage files on your WordPress website and providing some examples of when this might be useful especially when it comes to troubleshooting issues such as error messages and even critical problems that mean you’ve been denied access to your WordPress Admin.

One of the many reasons WordPress is so popular is thanks to its usability among non-tech orientated individuals. In other words, you don’t need to know how to code to build a great looking website with WordPress. The GUI (or graphical user interface) provided by WordPress means even those with limited IT experience can normally get the hang of building or editing a WordPress website fairly quickly.

There are some jobs however that require you to directly edit the underlying files that go to make up your WordPress website (of which there are typically thousands). In limited ways this can be done via the WordPress Admin but in most cases you will need to access the files held on your web hosts server. This is done using a tool like FileZilla or WinSCP which are referred to as SFTP clients. This is because they use a protocol called SFTP to communicate with your web server and in doing so allow you to transfer or update files on this server securely.

Let’s take a more detailed look at what SFTP is, why you might need to use it and how exactly to go about managing files on your WordPress website with SFTP.

What is SFTP?

In order to understand what SFTP is, we need to look at the precursor to it…FTP.

FTP (or File Transfer Protocol) is a standard network protocol that was built on a client-server architecture and is used to transfer files between an FTP host or server and an FTP client (computer/user) on the Internet.

File Transfer Protocol

FTP was first developed way back in 1971 and is still used under some circumstances today. It allows files to be directly transferred between a computer and a server. Importantly, all information that is transferred using FTP is normally unencrypted. This means that anyone can intercept this transfer which is a major security risk.

SFTP offers a logical successor to FTP. It stands for Secure File Transfer Protocol and overcomes one of a primary weaknesses of FTP (namely a lack of encryption). It is an extension of the SSH protocol and provides the ability to the user to securely connect to a remote server using the normal SSH port. This offers a number of advantages:

  • Secure: Data transferred via an SFTP connection is encrypted. This means any data intercepted by a third party would be unreadable.
  • Increased data transfer: More information can be provided about files transferred via SFTP. For example, users are able to access metadata like date, time, size, permissions and other information accurately while some FTP servers, especially older ones, may have trouble reading this information correctly (which can result in data anomalies as the metadata of local files does not match those on the server).
  • Firewall friendly: SFTP is firewall friendly as it exchanges data through a single connection. It does not use separate channels like FTP does and therefore does not force the server administrators to open up a range of ports like in case of FTP connections.
Secure File Transfer Protocol

How to I access my WordPress site via SFTP?

In order to connect to your WordPress website over the SFTP protocol, you will need:

  • A SFTP client that is compatible with your operating system that allow a user(client) to securely connect to a remote server
  • SFTP credentials for the server you wish to connect to. These will includes a host name, user name, password and port.

The exact method of connecting to an SFTP server will vary from web hosting provider to provider. It’s a common thing for users to want to do and any web host should be able to provide you with comprehensive instructions on how to access their servers via SFTP.

What SFTP Client Should I Use?

There are several great SFTP clients available for you to choose from. As a bonus, many of them are free to use! One of our favorites for Windows users is WinSCP. In addition to supporting SFTP (as you would expect!) it also supports a number of other protocols as well as boasting user-friendly features such as transfer resuming all bundled into an easy-to-use interface.

A popular alternative to WinSCP is Filezilla which is compatible with Windows, Linux and Mac OSX. It is easy to use, available in many languages and supports resume and transfer of large files.

Why do I need to use SFTP when managing my WordPress website?

There are lots of reasons why you would use SFTP to manage a WordPress website. We’ll list a few below.

Troubleshooting

Accessing your WordPress site via SFTP can be incredibly important when you’re trying to troubleshoot an issue.

Change File Permissions

File permissions determine the type of access permitted to a user. It is important to set the right permissions right after the WordPress installation otherwise you may experience fatal errors or encounter a blank white screen and even expose your website to malicious activity.

File permissions can ‘break’ however (sometimes for no apparent reason) and when this happens you’ll need to be able to use SFTP to reset them on your server. The most common sign that this has happened is when you get a “403 Forbidden error” when trying to visit a url on your website or are denied permission to upload files to your media library.

Problems like this can occur for a number of reasons. A common culprit is often a plugin that has altered the permissions of the files it accesses so disabling any recently installed (or updated) plugins can be a good place to start.

If you’re using WinSCP as your SFTP client you can change file permissions of a file or folder by right clicking on it and then heading to the ‘Properties’ menu.

You’ll see a list of the file permissions that are ticked (or not ticked) and can update accordingly.

Edit file permissions via SFTP

Fix “Briefly unavailable for scheduled maintenance. Check back in a minute” message

Anyone who has updated either a theme or plugin on their WordPress website and tried to view the site whilst this update was taking place would have seen a “Briefly unavailable for scheduled maintenance. Check back in a minute” message displayed.

Try our Award-Winning WordPress Hosting today!

This message should be temporary and be automatically taken down when the update of the plugin or theme is completed (unless a Maintenance plugin is being used to force this message to display). During updates like these a temporary .maintenance file is created in your website’s root folder and changes the website’s live mode to “maintenance mode”. This file is normally deleted after a few seconds when the updates complete

Occasionally however this message will continue to display after the update has been completed (which is of course rather annoying!). This could be due to a slow server response, a memory issue or a request timeout. In these cases the .maintenance file won’t be automatically deleted as should happen under normal circumstances.

To solve this problem you can access the root folder via SFTP and delete the .maintenance file. Hopefully this will mean your website now functions normally.

Note: As always, prior to undertaking any work on your WordPress website you should take a backup if possible.

Critical error on your website

Seeing the “Critical error on your website” message displayed on your WordPress site is understandably bound to raise your blood pressure especially as this error can sometimes prevent you accessing the admin area (or even the front end of the website).

The culprit in those cases is usually a conflict between plugins or theme/plugin and custom code.

The first step to remedy this is to recover access to your WordPress Admin. This is where using SFTP can prove so useful. To do this follow these steps:

  1. Log into your site server via SFTP and head to the root folder where you should see a folder called ‘logs’. If this isn’t accessible then talk to your hosting provider. Within these logs you’ll find a text document that can provide clues as to which element of your website is causing the critical error.
  2. For example you may see an error message in these logs that looks like this:

    “Got error ‘PHP message: PHP Fatal error: Uncaught Error: Class ‘WC_Subscriptions_Admin’ not found in /******-www/wp-content/plugins/woocommerce-subscriptions/woocommerce-subscriptions.php:73\nStack trace:\n#0 “

    This points us in the direction of the WooCommerce Subscriptions plugin
  3. Now we’ve identified the possible suspect for the critical error we need to disable the plugin. You can do this by renaming the folder. You might change it to something like “woocommerce-subscriptions.disabled”.
  4. Now, try and log into your WordPress Admin. If you can then you’ve solved the problem (in part). Now all is left to do is troubleshoot the problematic plugin.
  5. If you can’t identify which plugin might be causing problems from the WordPress logs (or you don’t have access to these), you can try disabling ALL the plugins. To do this rename the main ‘plugins’ folder to something like ‘plugins.disabled’. If you can now access the WP Admin you know that the issue is with a plugin. At this point you’ll then need to change the name of the plugin folder back to ‘plugins’ and then disable each plugin one by one by renaming them until you find the culprit.

If disabling your plugins doesn’t fix the ‘critical error’ issue then it’s worth seeing if it’s your theme that is the culprit. The method for doing this is basically exactly the same as with the plugins.

  1. Login to your server via SFTP and navigate to the folder called ‘wp-content’. In this folder you’ll see a folder called ‘themes’. Open this and you will then see any themes currently loaded.
  2. As we did for our plugins, rename your active theme in order to disable it. This might mean changing it from ‘salient’ (for example) to ‘salient.disabled’.
  3. WordPress should automatically change to the default theme and you can then see if you can now access your Admin panel (and the Critical warning disappears). If so, you’ll now know that the problem lies with your theme and or a conflict with your theme and plugins. 

Configuration File Issues

You may from time to time come across certain issues that can only be fixed by editing your WordPress Configuration file (or wp-config.php). One such issue occurs when your WordPress site isn’t able to establish a database connection. When this happens you’ll see a warning such as this:

If this happens to you, you can check that your database username and password are correctly saved in the wp-config.php file. Open this file using your SFTP client and you should see something like this:

You’ll need to know what your database username and password is in order to check/update this file. Your WordPress host should be able to assist you with this.

Development Work

An SFTP client is a tool that will be used a lot by website developers as it gives them access directly to the files that go to make up a website (and in doing so complete control to make any changes needed to these). Common tasks undertaken by a developer include:

  • Edit the functions.php file to create custom functions, add hooks/actions, registering or ignore certain scripts.
  • Create custom templates for WordPress
  • Override a WordPress themes templates with a child theme
  • Customize the style of a websites by editing its CSS files
  • Work on Custom plugins

Other uses for SFTP

A common use of SFTP is for transferring large files that you don’t want to move via an online file transfer service (for example sensitive/private documents). SFTP is also great for adding different files to your web server for use through your website. This might include PDF’s or perhaps font files that are used to generate non-standard fonts for your website.

Summary

Learning how to access your WordPress website via SFTP in order to manage your WordPress files directly is a useful skill to have at your disposal. For anyone serious about maintaining and developing a website, an SFTP client and a firm understanding of how to use it is an essential part of their toolkit.

If you’ve never accessed your website via SFTP it can be a real eye opener to see just how many files go into making up your WordPress website. A familiarity with the underlying structure of your website can lead to several ‘ah ha’ moments when browsing through forums on WordPress.

Start Your 14 Day Free Trial

Try our award winning WordPress Hosting!

OUR READERS ALSO VIEWED:

See how Pressidium can help you scale
your business with ease.