Here’s how I set up WordPress to seamlessly use SSH, rather than FTP, for updates. Using this method, I never have to enter a password, never have to (S)FTP, never have to mess with file permissions.
Like the WordPress Codex says, there are two ways to setup WordPress to use SSH:
I already had the SSH SFTP Updater plugin installed, but if you don’t, it’s just a matter of installing like any other plugin. Once I had it installed, I had been entering my ssh password manually each time I wanted to update or install plugins, themes, etc. What a pain. (And insecure, until I set up my WordPress site to use SSL.)
To mitigate that pain, and have WordPress use password-less ssh, you need to create public and private keys on your web server. When you run the following command, you will be asked some questions. Make sure you leave the passphrase blank.
ssh-keygen -t rsa -b 4096
Two key files, id_rsa.pub and id_rsa, will be created in your ~/.ssh directory. Change in to that directory and copy your id_rsa.pub key to a file called authorized_keys.
cp .ssh/id_rsa.pub .ssh/authorized_keys
Now change permissions so WordPress can access those keys.
chmod 775 .ssh
chmod 644 .ssh/*
Next, so that WordPress won’t ask you what method to use when updating, edit your wp_config.php file with the following code:
And that’s it. You should now be able to update, install, delete plugins and themes from your WordPress without entering any ssh or (s)ftp information.