How to Use SSH to Access Your UltraStack WordPress VPS

How to Use SSH to Access Your UltraStack WordPress VPS on Platform i

When you are running a website or server, SSH can save you time by allowing you to directly view, manage, and edit files from the command line interface (CLI). In this guide, we will show you how to use SSH with your UltraStack WordPress VPS hosted with Platform i.

Connect to Your Server via SSH

  1. Generate an SSH Key & Add it to your server.
  2. Login to Platform i, open your Project, then click Manage.
  3. You can then copy your Hostname or IP Address to use for connecting.
    Copy Server Hostname and IP Address
  4. Here are some examples of how you can connect.

    Connect with Hostname:
    [email protected]

    Connect with IP Address:
    [email protected]

    You will then be connected to your Cloud VPS via SSH.
    Connected to Server Via SSH

Using Your Key for SFTP

Once you’ve Generated an SSH Key & Added it to your server, you can also use it for connecting via SFTP. Here are the settings you should use.

OptionSFTP Setting
HostYou can use your Hostname or IP address. You can view this in your project under the Overview section.
Usernameroot
PasswordPassword for the SSH Key you generated. In most cases, you should be able to leave this blank. This is due to using the public/private keys.
Port22

For more information, see our full guide on Connecting With SCP and SFTP.

Managing Services

In this section, we will go over the log locations and specific commands for managing services on your Cloud VPS with Platform i.

NGINX

Log Files

  • Access: /var/log/nginx/access.log
  • Error: /var/log/nginx/error.log

Start/Stop/Restart

  • systemctl (start|stop|restart|status|reload) nginx

Examples:

Start:

systemctl start nginx

Stop:

systemctl stop nginx

Restart:

systemctl restart nginx

View Status:

systemctl status nginx

Reload:

systemctl reload nginx

Main Config

  • /etc/nginx/nginx.conf

Site Config

Below is the location of your site’s NGINX configuration file. Be sure to replace vps#### with your actual VPS server number.

  • /etc/nginx/conf.d/vps####.inmotionhosting.com.conf

Apache

Below is the location of your site’s Apache log files. Be sure to replace vps#### with your actual VPS server number.

Log Files

  • Access: /var/log/httpd/ssl-vps####.inmotionhosting.com-access.log
  • Error: /var/log/httpd/ssl-vps####.inmotionhosting.com-error.log

Start/Stop/Restart

  • systemctl (start|stop|restart|status|reload) httpd

Start:

systemctl start httpd

Stop:

systemctl stop httpd

Restart:

systemctl restart httpd 

View Status:

systemctl status httpd

Reload:

systemctl reload httpd

Main Config

  • /etc/httpd/conf/httpd.conf

Site Config

Below is the location of your site’s Apache configuration file. Be sure to replace vps#### with your actual VPS server number.

  • /etc/httpd/conf.d/vps####.inmotionhosting.com.conf

MySQL

  • systemctl (start|stop|restart|status) mysql

Start:

systemctl start mysql

Stop:

systemctl stop mysql

Restart:

systemctl restart mysql

View Status:

systemctl status mysql

Reload:

systemctl reload mysql

Main Config

  • /etc/my.cnf

Extra Config

  • /etc/my.cnf.d/server.cnf

PHP

Log Files

  • Error: /var/log/php-fpm/wordpress-error.log
  • Slow: /var/log/php-fpm/wordpress-slow.log

Start/Stop/Restart

  • systemctl (start|stop|restart|status) php-fpm

Start:

systemctl start php-fpm

Stop:

systemctl stop php-fpm 

Restart:

systemctl restart php-fpm

View Status:

systemctl status php-fpm

Main Config

  • /etc/php-fpm.conf

Site Config

Below is the location of your site’s PHP configuration file. Be sure to replace vps#### with your actual VPS server number.

  • /etc/php-fpm.d/vps####.inmotionhosting.com.conf

Redis

Log Files

  • /var/log/redis/redis.log

Start/Stop/Restart

  • systemctl (start|stop|restart|status) redis

Start:

systemctl start redis

Stop:

systemctl stop redis

Restart:

systemctl restart redis

Main Config

  • /etc/redis.conf

Monit

Monit is an open source tool that is installed to assist in monitoring and maintaining your server.

Log Files

  • /var/log/monit.log

Start/Stop/Restart

  • systemctl (start|stop|restart|status) monit 

Start:

systemctl start monit

Stop:

systemctl stop monit

Restart:

systemctl restart monit

Status:

systemctl status monit

Main Config

  • /etc/monit.d/monitrc

Extra Service Config

  • /etc/monit.d/{httpd,mariadb,nginx,php-fpm,redis}

Extra Service Commands

  • monit (status|summary|report|validate)

View Status:

monit status

View Summary:

monit summary

View REport:

monit report

Validate:

monit validate

Using WP-CLI

Before you can execute any WP-CLI command, you must switch to the WordPress user with the following steps.

  1. Connect to your server via SSH.
  2. Run the following command:
    su - wordpress
  3. You can then use WP-CLI to manage and troubleshoot your site. More information on the available commands can be found at: https://developer.wordpress.org/cli/commands/

Logging in as the WordPress User Instead of Root

You may not wish to log in as the root user, either to provide your developer with access to your site or simply for safety’s sake. Follow these steps to set up a new key for logging in directly as the wordpress user.

  1. Once you’re logged in as root, enter the following command:
    su - wordpress
  2. Enter the following command, which will create the .ssh directory and create a new key:
    mkdir -p ~/.ssh && cd ~/.ssh/ && ssh-keygen
  3. Follow the interactive prompts to set up your new key, then enter the following command to copy it to your authorized_keys file and set the correct permissions (if you chose a different name for your key, replace id_rsa in the following command with your key file):
    cat id_rsa.pub >> authorized_keys && chmod 600 authorized_keys
  4. Copy the private key onto your local machine, and use the following command to log in as wordpress in the future, replacing the path to the private key, filename, and VPS hostname:
    ssh -i /path/to/key/id_rsa wordpress@vps#####.inmotionhosting.com

Connecting Your IDE/Code Editor

We will now show you how to connect to your Cloud VPS using an integrated development environment (IDE) and code editor. For this guide, we are covering Visual Studio Code (VS Code) and Sublime Text.

Using Visual Studio Code

You will need to download and install Visual Studio Code before following this section of the guide. 

  1. Open Visual Studio Code. If you are running in “Restricted Mode” when you first open VS Code, you can click Manage on top then Trust to enable all features.
  2. Click View then Command Palette. You can also click Ctrl+Shift+P to open the command palette.
    Viewing the Command Palette in Visual Studio Code
  3. Type “remote” in the search box then click the Remote: Install Remote Development Extensions option.
    Searching and Install Remote Development Extensions
  4. You will then see the “Remote – SSH” option listed, click the Install button.
    Installing Remote - SSH in Visual Studio Code
  5. Click View then Command Palette again and type remote in the search box then click Remote-SSH: Connect to Host…
    Connecting to a Host with Remote-SSH in Visual Studio Code
  6. Enter your SSH login info as described above in the section on how to Connect to Your Server via SSH. Then click the Enter key.
    Logging into My Server with Visual Studio Code

    Visual Studio Code will open a new window that is connected to your server. From there you can create a new file, open a file, open a folder, or clone a Git repository. 
  7. In this example, we are going to click Open File to access an Apache configuration file.
    Opening a Remote File with Visual Studio Code
  8. Now I’m going to enter the path to the file I want to open then click OK.
    Searching for a Remote File With Visual Studio Code

    The file will then be open and you can view or edit it as needed.
    Editing a Remote File With Visual Studio Code

Using Sublime Text

You will need to download and install Sublime Text before following this section of the guide. 

  1. Open Sublime Text and click Tools, then Command Palette. You could also click Ctrl+Shift+P to open the Command Palette.
  2. Type install in the search box then click Install Package Control.
    Searching for Package Control
  3. You will then see a message stating “Package Control was successfully installed”. Click the OK button.
    Package Control was Successfully Installed
  4. Now go to Tools then Command Palette and type “package control” then click the Install Package option.
    Installing Package Control
  5. Enter “remotesubl” in the search field then click RemoteSubl from the list. It will be installed automatically once clicked.
    Search and Install Remote Sublime - RemoteSubl
  6. Run the following commands:
    sudo curl -o /usr/local/bin/rmate https://raw.githubusercontent.com/aurora/rmate/master/rmate

    sudo chmod +x /usr/local/bin/rmate

    sudo mv /usr/local/bin/rmate /usr/local/bin/sublime
  7. Logout and back into SSH and include the port, for example:
    ssh -R 52698:localhost:52698 [email protected]

    Important: You must have Sublime Text open for the next step to work.
  8. You can then open a file by using the sublime command. For example, I can open the NGINX access log with Sublime text by using the following command:
    sublime /var/log/nginx/access.log

Congratulations, now you know how to use SSH to access your UltraStack WordPress VPS from Platform i!

Was this article helpful? Join the conversation!