dongliang1996 2015-10-31 06:38
浏览 95

使用SSH更新Wordpress插件

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.

  • 写回答

1条回答 默认 最新

  • dongxing5525 2015-10-31 09:04
    关注

    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

    评论

报告相同问题?

悬赏问题

  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)