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.
[…] UPDATE: Found a way of using SSH without requiring any additional plugs, see: Using SSH for WordPress Automatic Updates. […]