WordPress SSH: Beginner’s Essential Guide

Using SSH is like cooking with a sharp chef’s knife. You get quick and precise cuts. But, it can be intimidating and not for every kitchen. It’s what the experts use and they use it for a reason. Other tools like cPanel and FTP clients are more approachable. They’re more beginner-friendly. But they’re not as good as the clean-cut of SSH. 

WordPress SSH offers unparalleled control and speed for managing your website. Instead of clicking through endless menus, you’re flying through tasks with a few precise commands. For those ready to learn its language, SSH replaces the inefficiency of other tools with a streamlined, secure process. 

TL;DR: WordPress SSH offers powerful and efficient website maintenance tool but comes with a learning curve. If you’re new, consider starting with alternatives like cPanel or Plesk for user-friendly interfaces before diving into SSH’s complexities.

SSH, which stands for Secure Shell, is a tool that enables secure communication with your server via the command line. It makes it possible to manage your WordPress site through simple, one-line commands. This means you can perform tasks quickly and efficiently. 

We’ve used SSH for a lot of testing. There’s a bit of a learning curve. But, once you learn the commands, the WordPress world is your oyster. In this article, we will give you a basic understanding and some common commands you can test out. 

Prerequisites for WordPress SSH

Before you can start using SSH to manage your WordPress site, there are a few essentials you’ll need to have in place:

  • SSH client: This software, like PuTTY or Terminal, allows you to connect to your server using SSH. Most computers come with an SSH client pre-installed. For example, on macOS and Linux-based systems, the Terminal application usually has SSH capabilities built-in. You can access it by searching for “Terminal” in the applications menu. Similarly, Windows has Command Prompt, and now Windows Subsystem for Linux (WSL) too. 
  • SSH access to the server: Ensure your hosting provider allows SSH access. Not all providers offer this, so it’s important to check. Look for mentions of SSH or Secure Shell access in the details. Another method is to directly contact their customer support via chat or email, asking if SSH access is available for your specific plan. 
  • Root access: Having root access means having full administrative control over a server, allowing you to manage all settings and configurations. While not always necessary (or possible on shared hosting), root access can be required for certain tasks, depending on what you need to accomplish on your server. For example, you need root access for updating server configuration files, such as those for Apache or Nginx, to change server request handling. However, you do not need root access for uploading or editing WordPress theme files, as this task involves managing files within the WordPress installation.
  • Stable network connectivity: This feels like a given but we’ve failed many manual backups because of spotty network. A reliable internet connection is crucial to maintain a steady session with your server via SSH.
  • User credentials: You’ll need your username and password or an SSH key to authenticate and gain access to your server. You will also need the public IP address. These are details you can find on your hosting account dashboard. 
  • Editor (either nano or vi): With SSH, you’ll often need to edit files directly on the server. Familiarity with text editors like nano or vi will be very helpful for making changes seamlessly.

How to connect to the server using WordPress SSH

Connecting to your server via SSH is a powerful way to manage your website directly from the command line. This secure method allows you to execute commands and perform tasks efficiently. Here’s a simple guide to help you connect using SSH:

  1. Open your SSH client: Start by launching your SSH client. On Windows, you might use PuTTY or Command Prompt, while macOS and Linux users typically use the Terminal application.
  2. Enter the command: You’ll initiate a connection by typing a command. The basic format is:
ssh username@your-server-ip 

Replace username with your SSH username and your-server-ip with your server’s address. This command connects you to the default SSH port (22).

  1. Authentication: After running the command, you might be prompted to enter your password or passphrase. Provide the necessary credentials to proceed.

Once you enter the correct information, you should successfully connect to your server, allowing you to start managing it through the command line.

When you’re finished with your tasks on the server, properly exiting your SSH session is important to ensure security. To disconnect from the server, simply type the command:

exit

How to find and modify a file using SSH

Using SSH, you can easily locate and modify files on your server. For instance, increasing the memory limit in a WordPress site involves editing the wp-config.php file. Here’s a step-by-step guide on how to edit a file:

  1. Connect to your server: Start by opening your SSH client and connecting to your server with the command:
ssh username@your-server-ip
  1. Navigate to your WordPress directory: Once connected, change directories to where your WordPress installation is located. Use the following command:
cd /path/to/your/wordpress/ 

Replace /path/to/your/wordpress/ with the actual path on your server. You need to know where on the server your WordPress site is installed. In our case it was: 

/var/www/html/wordpress/
  1. Open the file in an editor: For example, we are using nano to open the wp-config.php file with this command:
nano wp-config.php
  1. Edit the file: In nano, add or update the line. For example:
define('WP_MEMORY_LIMIT', '256M'); 
  1. Save changes in the editor: Using nano, to save your edits, press CTRL + O and then hit Enter. After saving, you can exit it by pressing CTRL + X.
  1. Log out of the server: When you’re finished, disconnect from the server by entering:
exit

How to access your database using SSH

Accessing your database through SSH provides a secure and efficient way to manage your data directly from the command line. Here’s a step-by-step guide on how to connect and interact with your database:

  1. Connect to your server via SSH: Begin by opening your SSH client and connecting to your server with the following command:
exit
  1. Navigate to the database command-line tool: Once connected, access your database management system by entering:
mysql -u db_username -p 

Replace db_username with your database username. If you’re using a different database like PostgreSQL, you’ll need to modify the command accordingly.

  1. Enter your database password: After executing the command, you’ll be prompted to enter your database password. Once authenticated, you can begin running SQL commands to interact with your database. For example, to list all databases on your server, type:
SHOW DATABASES;
  1. Exit the database: When you’re finished interacting with the database, exit the command-line tool with:
EXIT;
  1. Log Out of SSH: Finally, disconnect from the server by typing:
EXIT;

How to install WordPress using SSH

This section on installing WordPress using SSH assumes you already have a web server set up and ready to go. Installing WordPress via SSH allows for a fast and secure setup process. Here are the steps to get WordPress up and running:

  1. Connect to your server via SSH:
  1. Download and extract WordPress files: Use wget to download the latest WordPress package:
wget https://wordpress.org/latest.tar.gz
tar -xzvf latest.tar.gz
  1. Configure wp-config.php: Copy the sample configuration file and edit it with your database details:
cp wp-config-sample.php wp-config.php
nano wp-config.php 
  1. Complete the installation: Open your web browser and navigate to your server’s IP or domain name. You should see the WordPress installation screen, where you can finish the setup by providing site details and an admin account.

How to update WordPress plugins, themes, or core files using SSH

Updating your WordPress installation through SSH ensures a swift and secure process, especially important for maintaining site security and performance. 

Update WordPress core

Updating WordPress using SSH  requires downloading the latest version of WordPress directly from the official site, extracting it on your server, and carefully copying over the new files to replace the old ones. You need to be cautious not to overwrite wp-config.php or the wp-content directory, as these contain your configurations and custom content, respectively.

Update themes and plugins

For updating plugins and themes, you manually download the latest versions from WordPress.org or the developer’s site. After transferring the ZIP file to your server, you extract it into the appropriate directory (wp-content/plugins/ for plugins or wp-content/themes/ for themes). 

This method requires you to understand file structures and how plugin directories work. 

  1. Download the zip folder: Download it from the repository or the plugin developer’s site. 
  2. Upload the ZIP to your server: Use SCP, FTP, or another secure method to transfer the ZIP file to your server.
  3. Extract and replace the files: For Plugins, extract and replace the existing plugin directory.
unzip plugin-name.zip -d wp-content/plugins/

For themes, replace “plugin-name” with the actual theme name and “wp-content/plugins/

“ with the path to your theme folder. 

  1. Once updates are complete, exit SSH to close the connection:
exit

How to export files or a database table using SSH

Exporting files or database tables securely via SSH is a crucial task for backing up data or migrating between servers. Here’s a straightforward guide to achieve this:

Exporting site files

  1. Connect to your server via SSH: Open your SSH client and connect to your server:
ssh username@your-server-ip
  1. Navigate to the directory with files: Change to the directory containing the files you want to export. For example, here is the path to the plugin folder:
cd /path/to/your/wordpress/wp-content/plugins/
  1. Compress files into an archive: Use the tar command to create an archive of the files or directory:
tar -czvf blogvault_plugin_backup.tar.gz blogvault/
  1. Transfer the archive to your local machine: Use scp to securely copy the archive to your local system:
scp username@your-server-ip:/path/to/backup.tar.gz /local/directory/

Exporting a database table

  1. Connect to your server via SSH: Start with the SSH connection to your server:
ssh username@your-server-ip
  1. Access the MySQL or MariaDB command line: Enter the database command-line tool:
mysql -u db_username -p
  1. Export the database table: Use the mysqldump command to create an SQL dump of the table. For this tutorial, we’re exporting the wp-users table with the following command:
mysqldump -u db_username -p database_name wp_users > wp_users_backup.sql
  1. Transfer the SQL dump to your local machine: Use scp to copy the dump file over:
scp username@your-server-ip:/path/to/twp_users_backup.sql /local/directory/

Common commands for using SSH

SSH is a powerful tool for remote server access, enabling efficient management and operation of your server. Whether you are administering a server or managing database interactions, knowing the right commands can make tasks smoother and faster. Here’s a list of some common SSH commands to help you get started:

List files in a directory: View all files and directories in the current location with detailed information:

scp username@your-server-ip:/path/to/twp_users_backup.sql /local/directory/

Change directory: Move to a specific directory to access or manage files:

cd /path/to/directory/

Go up one directory level: Navigate to the parent directory:

cd ..

Remove a file: Delete a specific file from the server:

rm filename

Copy a file: Duplicate a file from one location to another on the server:

cp source-file destination-file

Open a file in Nano: Edit a file using the Nano text editor:

nano filename

Check current directory: Display the full path to your current working directory:

pwd

Note on using SSH commands

  • Syntax: When typing commands, pay attention to hyphens and spaces as they determine the function and parameters of a command.
  • Not case sensitive: SSH commands are generally not case sensitive, meaning you can type them in lowercase.
  • Enter after every command: Press the Enter key after typing a command to execute it.
  • Navigation with up and down arrows: Use the up and down arrow keys to cycle through previously executed commands, which is useful for repeating or modifying past tasks.
  • Left and right arrows for editing: You can use the left and right arrow keys to move within the command line, allowing you to make quick corrections without retyping the entire command—perfect for fixing small mistakes.

Pros and cons of SSH

SSH, or Secure Shell, is an essential tool in server management, offering both benefits and some challenges. Here’s a breakdown of the pros and cons:

Pros

  • Security: SSH provides encrypted communication, ensuring that data transferred between your local and remote systems is secure from eavesdropping and attacks.
  • Remote access: Facilitates remote access to servers, allowing administrators to manage and troubleshoot systems from anywhere with an internet connection.
  • Efficiency: Command-line operations via SSH are often faster and more efficient than graphical user interfaces, particularly for experienced users.
  • Versatility: Supports various functionalities such as file transfers (SCP, SFTP), port forwarding, and more, making it a versatile tool for different tasks.
  • Automation: Ideal for scripting and automating routine tasks, saving time on repetitive processes.

Cons

  • Complexity: Can be daunting for beginners due to the need to understand command-line syntax and operations.
  • Misconfiguration risk: Incorrect settings or commands might lead to security vulnerabilities or system issues.
  • Learning curve: Requires learning and familiarity with command-line operations, which can be challenging for those accustomed to graphical interfaces.
  • Limited by permissions: Some operations require elevated permissions, necessitating careful management of root access to avoid potential misuse.
  • No graphical elements: Lacking a visual interface can make some tasks more cumbersome for users who prefer visual cues and point-and-click accessibility.

Final thoughts

SSH may initially seem technically challenging to set up and use, especially for those new to command-line environments. 

However, mastering SSH can empower you with an efficient and secure method for managing your website. The ability to perform complex tasks quickly and remotely offers convenience and control that are unmatched by traditional interfaces. 

With practice, SSH can become your go-to tool for website and server management, transforming potentially time-consuming tasks into straightforward operations. Embracing SSH is about unlocking a powerful resource that, once grasped, significantly enhances your technical capabilities.

FAQs

What is SSH?

SSH, or Secure Shell, is a protocol used for securely accessing and managing a remote server over an encrypted connection. It allows users to execute commands, transfer files, and perform administrative tasks while ensuring data integrity and confidentiality.

How to access SSH in wordpress?

Accessing SSH for WordPress involves connecting to your server where WordPress is hosted. You need an SSH client like PuTTY (on Windows) or Terminal (on macOS/Linux). Use your server credentials to log in, typically via a command like ssh username@your-server-ip. Ensure your hosting provider supports SSH access.

How to install wordpress SSH?

You don’t install SSH for WordPress directly. Instead, you use SSH to interact with the server hosting your WordPress installation. Ensure your server is configured with SSH access, and use an SSH client to connect. From there, you can download and install WordPress using command-line commands.

How to access a website with SSH?

To access a website with SSH, connect to the server where the site is hosted. Use an SSH client to log in with your credentials. Once connected, navigate to the directory where the website files reside and manage them through the command line.

How to connect to a WordPress server?

To connect to a WordPress server using SSH, you’ll need your SSH login credentials and an SSH client. Open the SSH client and enter the command ssh username@your-server-ip, replacing placeholders with your actual server details. Once connected, you can navigate the server’s directories to manage your WordPress installation.

Tags:

You may also like


Fix: WordPress 403 Forbidden
Fix: WordPress 403 Forbidden

Stuck with a “403 Forbidden” error while trying to access your WordPress site? It’s a little scary and quite cumbersome but you can troubleshoot WordPress errors like this.  It’s a…

Fix: WordPress 413 Request Entity Too Large
Fix: WordPress 413 Request Entity Too Large

Fixing errors in WordPress site is like hitting a digital roadblock. It can be frustrating and disruptive. But, you’re also left wondering why this is happening to you.  The “413…

How do you update and backup your website?

Creating Backup and Updating website can be time consuming and error-prone. BlogVault will save you hours everyday while providing you complete peace of mind.

Updating Everything Manually?

But it’s too time consuming, complicated and stops you from achieving your full potential. You don’t want to put your business at risk with inefficient management.

Backup Your WordPress Site

Install the plugin on your website, let it sync and you’re done. Get automated, scheduled backups for your critical site data, and make sure your website never experiences downtime again.