Using SSH for Wordpress Automatic Updates

Using SSH for WordPress Automatic Updates

Been a lot of geekery on this blog recently, apologies, triviality and cantankerism to return soon, honest.

Plugins like SSH-SFTP-Updater-Support provide an easy way to use SSH for plugin, theme and core updates but requires a manual process each time. In its recent release  Wordpress 3.7 enabled automatic background updates – no-one wants to wait for a security patch, right?

Came across this handy code for anyone who is running a WordPress installation but using SSH for additional security – never a bad thing – it means updating the core, plugins and themes manually each time. Add a few lines to wp-config.php and WordPress should take care of it automatically:

/**
 * Cribbed from blog post: http://blog.blenderbox.com/2012/10/23/update-wordpress-plugins-over-ssh/
 * Allows WordPress to use SSH without needing an additional plugin
**/
define('FS_METHOD', 'direct'); // 'ssh' is also an option, but did not work for my setup
define('FTP_BASE', dirname(__FILE__)); // set this to your docroot
define('FTP_CONTENT_DIR', FTP_BASE.'/wp-content/');
define('FTP_PLUGIN_DIR ', FTP_CONTENT_DIR.'/wp-content/plugins/');
define('FTP_PUBKEY', $_ENV['HOME'].'/.ssh/wpkey.pub'); // make sure you've added this as a deploy key before you do this
define('FTP_PRIKEY', $_ENV['HOME'].'/.ssh/wpkey');
define('FTP_USER', `whoami`);
define('FTP_HOST', 'localhost:2233'); // or whatever port you're using for SSH

Voila! Seems to the job.

Pic (cc) Tudor Baker on Flickr.

About 

Inquisitive. Hopeful. Jovial. Cantankerous. Digital marketer. Event organiser. Long-time fan of tech, collaboration and innovation. Exploring digital, social, business, technology, society, psychology & startups. Founder Chinwag, Digital Mission, Pitch NYC, ChinwagPsych. Former Exec Dir, Social Media Week London. More short stuff @toodlepip on Twitter.

  • facebook
  • linkedin
  • twitter
  • flickr
  • googleplus