clubmate.fi

A good[ish] website

Web development blog, loads of UI and JavaScript topics

Enable plugin and theme updates over SFTP on WordPress

Filed under: WordPress/PHP— Tagged with: ftp, snippets, nginx

Here’s a quick post on making WordPress SFTP friendly.

If using FTP, plugin and theme updates work and all is nice and dandy, but please god have mercy on you if SFTP.

This screen will get familiar for sure:

WordPress FTP credential prompt

Configuring WP

You can fill in the FTP credential prompt every time, or put the following to wp-config.php file.

// Path to your key files, if you got multiple key files remember to
// use the right key here.
define('FTP_PUBKEY', '/home/user/.ssh/id_rsa.pub');
define('FTP_PRIKEY', '/home/user/.ssh/id_rsa');

// The SFTP user goes here.
define('FTP_USER', 'user');

// This was a culprit for me once, didn't work without it.
// Possible values: "direct", "ssh2", "ftpext", or "ftpsockets".
define('FS_METHOD', 'direct');

// Hostname, define a custom port here if in use.
define('FTP_HOST', 'example.com:73000');

See more possible options here.

Additional server components to install

Also, might need to have libssh2-php installed:

$ sudo apt-get update && apt-get install libssh2-php

After install restart your webserver, most likely it's Apache or NGINX:

# NGINX
$ service nginx restart

# Apache
$ service apache2 restart

Hope this was helpful. Have a nice day!

Comments would go here, but the commenting system isn’t ready yet, sorry.

  • © 2022 Antti Hiljá
  • About
  • All rights reserved yadda yadda.
  • I can put just about anything here, no one reads the footer anyways.
  • I love u!