• Skip to main content
  • Skip to primary sidebar

Technical Notes Of
Ehi Kioya

Technical Notes Of Ehi Kioya

  • Forums
  • About
  • Contact
MENUMENU
  • Blog Home
  • AWS, Azure, Cloud
  • Backend (Server-Side)
  • Frontend (Client-Side)
  • SharePoint
  • Tools & Resources
    • CM/IN Ruler
    • URL Decoder
    • Text Hasher
    • Word Count
    • IP Lookup
  • Linux & Servers
  • Zero Code Tech
  • WordPress
  • Musings
  • More
    Categories
    • Cloud
    • Server-Side
    • Front-End
    • SharePoint
    • Tools
    • Linux
    • Zero Code
    • WordPress
    • Musings
Home » Linux & Servers » WordPress Updates & Installations Via SSH

WordPress Updates & Installations Via SSH

By Ehi Kioya 1 Comment

SSH provides a significantly more secure way of updating WordPress files and plugins or performing new plugin installations. Three immediately obvious advantages of SSH over FTP are:

  1. Your username and password is encrypted. FTP sends them as plain text!
  2. Data being transferred is encrypted. No encryption with FTP.
  3. Some web hosts don’t allow the use of FTP.

Here, I explain how to enable WordPress to use SSH for all updates and installations.
 

Install Process For SSH2

You first need to check if the PHP extension “SSH2” is installed on your server or not by running the following command:

1
php -m | grep ssh2

If it returns “ssh2”, that means it is installed. You should proceed to the next section and create a public and private key pair.
If it returns nothing, then complete the steps in my previous post to install ssh2 for php. After completing those steps, proceed to the next section and create the key pair.
 

Create a Public and Private Key Pair For WordPress.

On the command line on your server, log in as the user that has access to the site. Then run this command:

1
ssh-keygen

You will be asked for the name of the file. You can leave it blank or enter any custom name. If you leave it blank, the file names will be id_rsa.pub and id_rsa. Also you can set a passphrase to add additional security or can leave it blank.

By default, the SSH keys are generated and kept in the .ssh directory in the root directory. Now, we need to add the public key to the authorized_keys file:

cd .ssh
cp id_rsa.pub authorized_keys

Then we modify permissions to give WordPress access:

cd ../
chmod 755 .ssh
chmod 644 .ssh/*

Now, when you log into the WordPress admin dashboard and perform an action that requires a file transfer operation, such as installing or updating a plugin, you should be presented with more options for the connection type. Besides FTP, which was previously there, you should also have the SSH2 option. If you select SSH2, more fields will be added to the form.

The form will look like this:

WordPress Via SSH

Here “user” is the SSH username you used to log in and perform all the commands and the required password is the passphrase you were asked to set during the ssh-keygen command.

If you did not choose any passphrase, you should keep the password field blank. To avoid entering this data repeatedly, append the following lines of code to your wp-config.php file:

define('FTP_PUBKEY','/home/user/.ssh/id_rsa.pub');
define('FTP_PRIKEY','/home/user/.ssh/id_rsa');
define('FTP_USER','user');
define('FTP_PASS','passphrase');
define('FTP_HOST','yourdomain.com');

Going forward, WordPress will perform all file transfer operations using SSH2 and you won’t even have to manually authenticate!

Found this article valuable? Want to show your appreciation? Here are some options:

  1. Spread the word! Use these buttons to share this link on your favorite social media sites.
  2. Help me share this on . . .

    • Facebook
    • Twitter
    • LinkedIn
    • Reddit
    • Tumblr
    • Pinterest
    • Pocket
    • Telegram
    • WhatsApp
    • Skype
  3. Sign up to join my audience and receive email notifications when I publish new content.
  4. Contribute by adding a comment using the comments section below.
  5. Follow me on Twitter, LinkedIn, and Facebook.

Related

Filed Under: Linux & Servers, WordPress Tagged With: Ubuntu, WordPress

About Ehi Kioya

I am a Toronto-based Software Engineer. I run this website as part hobby and part business.

To share your thoughts or get help with any of my posts, please drop a comment at the appropriate link.

You can contact me using the form on this page. I'm also on Twitter, LinkedIn, and Facebook.

Reader Interactions

Comments

  1. sunshine says

    April 12, 2015 at 7:21 am

    Can you help me get my site working right (wordpress)? Thanks

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

26,207
Followers
Follow
30,000
Connections
Connect
14,641
Page Fans
Like

POPULAR   FORUM   TOPICS

  • How to find the title of a song without knowing the lyrics
  • Welcome Message
  • How To Change Or Remove The WordPress Login Error Message
  • The Art of Exploratory Data Analysis (Part 1)
  • Getting Started with SQL: A Beginners Guide to Databases
  • Replacing The Default SQLite Database With PostgreSQL In Django
  • Understanding Routes In Laravel
  • Building A Blog With Laravel – Part 6: Creating A Form For New Posts
  • Getting Started With JupyterLab
  • How To Become A Self-taught Programmer
  • Recently   Popular   Posts   &   Pages
  • Actual Size Online Ruler Actual Size Online Ruler
    I created this page to measure your screen resolution and produce an online ruler of actual size. It's powered with JavaScript and HTML5.
  • Allowing Multiple RDP Sessions In Windows 10 Using The RDP Wrapper Library Allowing Multiple RDP Sessions In Windows 10 Using The RDP Wrapper Library
    This article explains how to bypass the single user remote desktop connection restriction on Windows 10 by using the RDP wrapper library.
  • WordPress Password Hash Generator WordPress Password Hash Generator
    With this WordPress Password Hash Generator, you can convert a password to its hash, and then set a new password directly in the database.
  • Forums
  • About
  • Contact

© 2021   ·   Ehi Kioya   ·   All Rights Reserved
Privacy Policy