Skip to content

Websites · 2 min read

SSH Access and SSH Keys for WordPress Hosting

SSH gives you a secure command-line connection to your WordPress server. Use it to run WP-CLI commands for plugins and themes, import or export data, clear caches, change settings, and manage files. It's meant for people comfortable with the command line.
SSH only uses keys, not passwords, for extra security.

Step 1: Create an SSH key

Mac
  1. Open Terminal.
  2. Run ssh-keygen -t rsa and press Enter at each prompt.
  3. Copy the public key: pbcopy < ~/.ssh/id_rsa.pub
Linux
  1. Open a terminal.
  2. Run ssh-keygen -t rsa and press Enter at each prompt.
  3. Copy the public key: cat ~/.ssh/id_rsa.pub | xclip -sel clip
If xclip isn't installed, install it first: sudo apt install xclip (Ubuntu), sudo pacman -S xclip (Arch), or sudo yum -y install xclip (Fedora/CentOS).
Windows
  1. Open PowerShell.
  2. Run ssh-keygen.exe -t rsa and press Enter at each prompt.
  3. Copy the public key: Get-Content .ssh\id_rsa.pub | Set-Clipboard
Only ever share the public key (the .pub file). Keep the private key on your computer.

Step 2: Add the key to your hosting dashboard

  1. Open your site in the WordPress hosting dashboard.
  2. Go to Advanced Settings > Server Settings.
  3. Turn on SSH Access.
  4. Scroll to SSH Keys Manager and click Import New Key.
  5. Paste your public key and give it a name, like "Jane's MacBook". Leave the passphrase blank unless you set one.
  6. Click Import. The key is authorized automatically.

Step 3: Connect

  1. On the Server Settings tab, find your host (IP address) and username.
  2. In your terminal, run ssh yourusername@yourhostip with your own values.
  3. The first time, type yes and press Enter to trust the server.
  4. Go to your site folder: cd public_html

Handy WP-CLI commands

  • List plugins: wp plugin list
  • Clear the WordPress cache: wp cache flush
  • Clear the CDN cache: wp cdn purge

Manage keys

  • Delete keys you no longer use in SSH Keys Manager.
  • Import a key for each computer or team member.
  • Replace keys from time to time for better security.

Troubleshooting

  • Can't connect? Check the key is authorized and the username and host are right.
  • Clipboard command fails on Linux? Install xclip.
  • Key has a passphrase? Run ssh-add ~/.ssh/id_rsa first.

Did this answer your question?

No, I need help

More in Websites