Heres a quick how to on getting wordpress to update over SFTP. On a default install of php, wordpress only gives the option to update over FTP. I wanted to get it working as it’s more secure and means I don’t have to open up FTP on my virtual server and open another port up in the firewall.
I’m using ubuntu and the sequence of commands I followed were:
sudo apt-get install libssh2-1-dev libssh2-php
You should now find that if you list the modules installed in php and check if ssh2 is now there, you get the result “ssh2″:
php -m | grep ssh2
You’ll need to restart apache for the changes to begin being used.
sudo /etc/init.d/apache2 restart
If you head to updates in your dashboard, you should now see an extra option “SSH2″ and spaces for public and private authentication keys. I had to head back to the terminal and create these particular files.
cd ~ ssh-keygen cat .ssh/id_rsa.pub >> .ssh/authorized_keys chmod 755 .ssh chmod 644 .ssh/* sudo chown -R ian:www-data /var/www/pathtowordpress/
Now you can head into the updates page again, enter your username and password and the locations to your public and private keys (/home/ian/.ssh/id_rsa.pub and /home/ian/.ssh/id_rsa in my case). If you’re running ssh on a non standard port, be sure to append that to your hostname.
Thanks to the following helpful posts: http://kevin.vanzonneveld.net/techblog/article/make\_ssh\_connections\_with\_php/