• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here:Home » Automatic WordPress Update Via SSH Authentication

By Abhishek Ghosh March 30, 2015 6:48 am Updated on March 30, 2015

Automatic WordPress Update Via SSH Authentication

Advertisement

Here is How To Configure WordPress Automatic WordPress Update Via SSH Authentication For a Very Secured WordPress Setup on Multiple Nodes. Normally, if we do not CHMOD WordPress Directories and Files to writable, the WordPress installation asks for FTP username and password; which again we can bypass by adding one line in wp-config.php file. However, it is possible to setup more secure method of authentication, that is adding one SSH user and adding few lines in wp-config.php file. This guide on automatic WordPress update via SSH authentication is exactly for this setup.

 

Automatic WordPress Update Via SSH Authentication : Preparation

 

We need to have SSH2 extension installed for PHP. That depends on the Server OS, Version and Webserver. In general, for deb Linux we need to check by running :

Vim
1
php --ri ssh2

This should give this output :

Advertisement

---

Vim
1
2
3
4
5
6
ssh2
 
SSH2 support => enabled
extension version => 0.12
libssh2 version => 1.4.3
banner => SSH-2.0-libssh2_1.4.3

Else you need to check the documents to properly install it. Another way to check is to create a test.php file with the following content in FTP root :

Vim
1
2
3
4
5
6
7
8
<?php
 
if (function_exists('ssh2_connect'))
{
    echo "true";
}
 
?>

If you point to the PHP file from browser, you’ll see true as output for the right setup. Who are the owners of the WordPress files, that is important. Because, root‘s ~/.ssh location and other user’s ~/.ssh will be different.

Vim
1
2
cd ~/.ssh
cat authorized_keys

For OpenStack, you will have a Nova generated key. You can run ssh-keygen command and enter any custom nameto avoid the file names to be id_rsa.pub and id_rsa. Set a passphrase to add additional security. If ownership of the files is not correct, you’ll need to chmod these files :

Vim
1
2
chmod 755 ~/.ssh
chmod 644 ~/.ssh/*

 

Example of the Above

 

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
sudo adduser wordpress-user
cd /usr/share/nginx/html
sudo chown -R www-data:wordpress-user /usr/share/nginx/html/
sudo su - wordpress-user
cd ~
ssh-keygen -t rsa -b 4096
# save at
# /home/wordpress-user/wp_rsa
exit
sudo chown wordpress-user:www-data /home/wordpress-user/wp_rsa*
sudo chmod 0640 /home/wordpress-user/wp_rsa*
sudo mkdir /home/wordpress-user/.ssh
sudo chown wordpress-user:www-data /home/wordpress-user/.ssh/
sudo chmod 0700 /home/wordpress-user/.ssh/
sudo cp /home/wordpress-user/wp_rsa.pub /home/wordpress-user/.ssh/authorized_keys

 

Automatic WordPress Update Via SSH Authentication : Editing wp-config.php

 

Now, edit the wp-config.php file and add these lines :

Vim
1
2
3
4
5
6
7
8
9
10
define('FS_METHOD', 'ssh2');
define('FTP_BASE', '/usr/share/nginx/html');
define('FTP_CONTENT_DIR', '/usr/share/nginx/html/wp-content/');
define('FTP_PLUGIN_DIR ', '/usr/share/nginx/html/wp-content/plugins/');
define('FTP_PUBKEY','/home/wordpress-user/wp_rsa.pub');
define('FTP_PRIKEY','/home/wordpress-user/wp_rsa');
define('FTP_USER','wordpress-user');
define('FTP_PASS','********');
define('FTP_HOST','127.0.0.1:22');
// define('FTP_HOST','10.0.0.1:22');

Automatic WordPress Update Via SSH Authentication

We can further restrict by editing / adding the subnet like from="10.0.0.1" before ssh-rsa in this file :

Vim
1
/home/wordpress-user/.ssh/authorized_keys

FTP host will be edited rightly like shown above. In this case, you can restrict the access of the other nodes to wp-config.php file. Unless there are many nodes, this much security is usually not required.

Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to Automatic WordPress Update Via SSH Authentication

  • WordPress Multisite on Nginx on Ubuntu 14.04 on HP Cloud

    Here is a Step by Step Guide on Setting Up WordPress Multisite on Nginx on Ubuntu 14.04 on HP Cloud with All Commands and the Configuration.

  • Nginx WordPress Installation Guide (All Steps)

    This is a Full Nginx WordPress Installation Guide With All the Steps, Including Some Optimization and Setup Which is Compatible With WordPress DOT ORG Example Settings For Nginx.

  • How to Install WordPress : Ubuntu 16.04, Nginx, PHP7-FPM

    Here is Step by Step Guide on How to Install WordPress on Ubuntu 16.04, Nginx, PHP7-FPM, memcached & Percona MySQL 5.7 on Cloud Server or VPS.

  • Fix WordPress 4.7 Upgrade Failed : Nginx+PHP7+HTTPS+Genesis+W3TC

    Auto Update Likely to Break Website.Our Step by Step Guide To Fix WordPress 4.7 Upgrade Failed With Nginx, HTTPS, Genesis, W3 Total Cache.

performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Hybrid Multi-Cloud Environments Are Becoming UbiquitousJuly 12, 2023
  • Data Protection on the InternetJuly 12, 2023
  • Basics of BJT TransistorJuly 11, 2023
  • What is Confidential Computing?July 11, 2023
  • How a MOSFET WorksJuly 10, 2023
PC users can consult Corrine Chorney for Security.

Want to know more about us?

Read Notability and Mentions & Our Setup.

Copyright © 2023 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy