I need to update the plugins in my Wordpress site using the SSH command line. Any of you know a save way to do it?
I'll really appreciate your help.
I need to update the plugins in my Wordpress site using the SSH command line. Any of you know a save way to do it?
I'll really appreciate your help.
You can enable WordPress to use SSH for upgrading and plugin/theme installations. - First of all you need to check with your webhost if they have the SSH2 extension installed for PHP or not. To check for that run the following PHP command
var_dump( extension_loaded( 'ssh2' ) );
If this command returns true, that means it's installed, otherwise it's not. If your webhost doesn't offer it, ask them to install it for you or if you are running a VPS/dedicated, you can install it yourself.
First of all we need to generate a working set of public and private keys which will be used for authenticating the user. To do that, use the following command in your SSH client:
ssh-keygen
You will be asked for the name of the file. You can leave it blank or enter any custom name. If you leave it blank, the file names will be id_rsa.pub and id_rsa. Also you can set a passphrase to add additional security or can leave it blank.
Time to add keys needed to be added to the authorized_keys file. In our case, SSH keys were generated and kept in the .ssh directory in the root directory.
cd .ssh
cp id_rsa.pub authorized_keys
Now change permissions so that WordPress can access those keys.
cd ../
chmod 755 .ssh
chmod 644 .ssh/*
You may need to change the user of the directory if you are running PHP as a different user.
Now that you have got SSH2 setup and working, you should see the following screen while performing any upgrade/plugin or theme install.
Here user is the SSH username you used to login and perform all the commands and password is the passphrase you were asked to set during the ssh-keygen
command. If you didn't choose any passphrase, you should keep the password field blank. To avoid entering this data repeatedly, enter the following code in your wp-config.php
define('FTP_PUBKEY','/home/user/.ssh/id_rsa.pub');
define('FTP_PRIKEY','/home/user/.ssh/id_rsa');
define('FTP_USER','user');
define('FTP_PASS','passphrase');
define('FTP_HOST','domain.com');
From now on WordPress will perform all file transfer operations using SSH.
Source: enter link description here