If you have never used WP CLI before neither a command line interface, this guide is for you.
WP CLI is a powerful way to manage Wordpress and plugins. On the CLI interface, there is no such thing as timeout and you can import long files, clear the cache, backup your website and a lot more! Let's begin.
Creating the SSH Key
At Rocket, we do not allow SSH access by a password for security reasons. Without a password, no one can try to guess or brute force your password because there isn't one :)
So the first thing that you need to do is to create an SSH key. It may appear hard at the beginning, but it's really straightforward.
Mac OS
If you use Mac, the first thing you need to do is to open a terminal. Once your terminal is open, you can copy and paste the following command:
ssh-keygen -trsa
Hit enter for all the options, you don't need to create a password. It should look like this(on Mac terminal is usually white instead of black, but should be the same):
Once your key is created, you can copy it to your clipboard:
pbcopy < ~/.ssh/id_rsa.pub
Linux
On linux, it's the same thing! You can open a terminal (any of them) and then type the same command to create the ssh key. :
ssh-keygen -trsa
Once the ssh key is created, you can copy it to your clipboard with:
cat .ssh/id_rsa.pub | xclip -sel clip
If you receive an error saying "xclip command not found" you can just install the package at your distribution. For Ubuntu you can use:
sudo apt install xclip
For Arch Linux:
sudo pacman -S xclip
For Fedora/CentOS:
sudo yum -y install xclip
Windows
On Windows, it's the same command as well to generate the ssh key. You won't find a software called "Terminal" on Windows. Instead, you can use Powershell. Click on Start and type in "powershell" and click on the PowerShell icon:
Once you open Windows PowerShell you can type the following command:
ssh-keygen.exe -trsa
Then just hit enter for alal questions. Once you finished that, you can use the following command to copy the key to your clipboard:
Get-Content .ssh\id_rsa.pub | Set-Clipboard
Part 2 - Adding the key at Rocket.net
At Rocket, go to sites and click on "Manage" at the website that you want to connect to:
Then go to Advanced and make sure to enable SSH access:
Now scroll down a bit more until you see this section. Under this section, click on "Import New Key":
Under the "Key" field, paste the key that was in your clipboard:
You can use any "Key name" and leave Key Passphrase blank.
After you added it, make sure to authorize it as well:
Now we are all set! We just need to connect to the server. To do so, go to the Overview tab, and then grab the FTP/SSH/SFTP address and the SSH/SFTP username.
Once you have that, you can go back to the Terminal/Windows Powershell and then connect with the following command:
ssh sftpusername@FTPAddress
Of course, replace the sftpusername and the FTPaddress with the correct details.
If it is the first time that you are connection, you will probably receive this warning:
You can just write "yes" and hit enter.
Boom! Now you are inside your site by using command line:
First thing you need to do is to go to public_html. To do so, use
cd public_html
Now you can finally use any commands that you want. You can purge the cache for example with:
wp cache flush
Or you can also clear our CDN cache with:
wp cdn purge
Or even cooler, you can get your current domain with:
wp option get home
You can learn more about wp-cli and its various commands at the WP CLI documentation. And if you run into any trouble, don't hesitate to reach out to our Support for assitance!
Comments
0 comments
Article is closed for comments.