Josheli
  • Home
  • Blog
    • Knob
    • Running
    • Soccer
    • Technology
  • Projects
    • Overview
    • No Instagram
    • Google Photos WordPress Plugin
    • Plex Channels
    • Sh***y Game
    • Soccer In Colorado
    • Statrat
    • The Dot Game
    • Vox cPanel Hacks
    • WW Points Calculator
  • About
Knob , Technology

Setting up WordPress to use SSH for Updates

by dv December 18, 2015 No Comments

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:

  • The SSH SFTP Updater plugin
  • SSH2 PHP Extension

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.

cd ~/.ssh/
cp .ssh/id_rsa.pub .ssh/authorized_keys

Now change permissions so WordPress can access those keys.

cd ..
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:

define('FTP_PUBKEY','/home/user/.ssh/id_rsa.pub');
define('FTP_PRIKEY','/home/user/.ssh/id_rsa');
define('FTP_USER','user');
define('FTP_PASS','');
define('FTP_HOST','127.0.0.1:22');
define('FS_METHOD', 'ssh2');

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.

It's only fair to share...Share on facebook
Facebook
Share on twitter
Twitter
Share on email
Email

Related Content:

  • Installing Let's Encrypt SSL on Nginx and WordPress by Dv December 19, 2015 Here's how I installed the free Let's Encrypt SSL certificate on Nginx to use with this WordPress site. I used…
  • Simple Google Photos: A WordPress Plugin by Dv November 21, 2017 So I wrote a WordPress plugin to display photos from a public album on Google Photos. You can also get…
  • MariaDB or MySQL Root Password Struggles on Debian/Ubuntu by Dv March 14, 2018 Had a difficult time authenticating to a newly installed MariaDB 10.1 instance on Debian 9 (Stretch) recently, wasting a couple…
  • Tweet Tweet, Josheli Tweets by Dv November 28, 2017 For no good reason I wrote a little code to tweet out random posts from this very WordPress blog. I…
  • Which ruby? by Dv February 26, 2011 Playing around with Ruby, Rails, RefineryCMS... anything installed? ~ $ which ruby nope, ok... ~ $ sudo apt-get install ruby…
  • Previous Running a Plex Media Server on an Old Laptop7 years ago
  • Next Installing Let’s Encrypt SSL on Nginx and WordPress7 years ago

Leave a Reply

Your email address will not be published. Required fields are marked *

Popular Posts

  • Josheli, What Happened? (26,965)
  • Install Ubuntu on HP Laptop with UEFI and new SSD Hard Drive (14,434)
  • Running a Plex Media Server on an Old Laptop (12,963)
  • Simple Google Photos: A WordPress Plugin (11,573)
  • More Janky Snowboarding Video (10,796)

Random Read

More thoughts
After Fila Relays last year, my takeaway was "No More Races". After 3M it was…

Read More

Google Photo
Google Photo
Google Photo
Google Photo

Social Things

  • Family Photos
  • Juiskie’s Instagram
  • Scooter’s Facebook
  • Scooter’s Instagram
  • YouTube Videos
  • DV’s Github
  • Tweet Tweet

RSS From Familyvance

  • Snowshoeing at Brainard Lake
  • Fishing and Hiking at Golden Gate Canyon State Park
  • Rainbow Trout Fishing Report at Waneka Lake
  • Weightless Texas-Rig Plastic Worms at Sawhill Ponds and Coot Lake
  • Sawhill Ponds Fishing Report
2023 Josheli. Donna Theme powered by WordPress