Command Download Via Ssh Mac Average ratng: 3,4/5 413 votes

Learning how to use SSH to access your WordPress site is something you may not have considered. For most WordPress users, the most familiar way to connect to your site will be via the WordPress dashboard and admin screens, combined with SFTP and phpMyAdmin to access the database.

  1. May 01, 2019.
  2. Jan 20, 2011.
  3. I forgot to turn on 'VNC viewers may control screen with password', to enter on my working Mac, is there way to turn-on this feature remotely via SSH (I'm on WindowsXP now)? Stack Exchange Network Stack Exchange network consists of 176 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn.
  4. Once your public key has been added, you can now connect to SSH via the command line. Using your terminal program of choice (like Terminal or iTerm for Mac, or PuTTY for Windows), you can view a list of all sites you have access to or connect directly to one of them.

But SSH might just prove to be one of the most valuable tools in your WordPress toolbelt.

If you want to speed up your workflow, you’ll find that learning how to use SSH to connect to your WordPress site will make you more efficient.

In this post, we’ll show you how to do it.

What is SSH?

Command

First, let’s start by identifying what SSH is and when you might use it.

Jun 05, 2020. May 15, 2018.

SSH means ‘Secure Shell’. The SSH specs define it as:

“A protocol for secure remote login and other secure network services over an insecure network.”

This means you can use it to access your WordPress site remotely, from any computer and regardless of where your site is hosted, as long as you have the login credentials. Using this method is inherently secure.

SSH is designed to provide secure login, so you can be confident no one can access your connection while you are using it. It’s also quick and easy to use once you’ve got the hang of it. And if you want to interact with the WordPress REST API, it’s one way to send commands.

To connect to your server via SSH, you’ll need two things:

  • An interface.
  • Login credentials.

If you’re running Linux or macOS, you have an interface built into your operating system, so you don’t need to install an SSH client. But if you’re running Windows, you’ll need to install a client. I’ll show you how to do that in this post.

Tools You Need to Connect to Your Site via SSH

To start, you’ll need to use either the terminal or an SSH client. These work in very similar ways.

Connecting via the Terminal on macOS or Linux

The Terminal is an application that comes with Linux or macOS, that allows you to use the command line to send commands, either to your machine or to a remote server.

It isn’t a graphical interface so you won’t be using a mouse. Instead, you type in text commands. For a first-time user, it can be little disconcerting, as you’re probably used to seeing visual representations of your commands. But once you get used to it, you’ll find it quicker.

If you worked with computers in the days before graphical user interfaces, using systems such as Microsoft’s MS-DOS, you might be familiar with this kind of interface. The good news is that the Terminal gives you many more options than MS-DOS did!

To open the Terminal on Mac, open Spotlight and type Terminal. You can also access it via Applications > Utilities.

To open Terminal on Linux, find it in the Applications menu. If it isn’t immediately obvious, type Terminal into the prompt to find it.

Connecting via an SSH Client on Windows

An SSH client is a program that you’ll need to install if you’re running Windows, in order to connect via SSH.

The most popular SSH client is PuTTY. You’ll need to download and install that before you can access your site from Windows.

Download PuTTY

Installing the Putty SSH Client on Windows

Start by going to the PuTTY download page.

From here, choose the package that corresponds to your version of Windows. If you aren’t sure whether to download the 32-bit or 64-bit version, check out the FAQ page. If in doubt, the 32-bit version is the safer option.

Click on one of the two options under MSI (‘Windows Installer’). The file will download to your machine and run the installer.

Once PuTTY has installed, open it and you can then use it to connect to your site.

How to Connect to Your Server via the Command Line

Once you’ve found or installed the Terminal or an SSH client, the next step is to connect to your remote site.

In either Terminal or an SSH client, you use the command line to connect and send commands to your server. That’s the terminology I’ll use from now on, instead of referring to Terminal or an SSH client.

To do this, you’ll need four pieces of information:

  • Server address.
  • Username.
  • Password.
  • Port.

The server address is usually your domain name or IP address. If your site is hosted with Kinsta, use your IP address.

The username and password will be your FTP username and password, not the ones for your WordPress admin.

The port will be provided by your hosting provider. In some cases, a default port is used, but for extra security at Kinsta, we use different ports for different sites.

In MyKinsta, you can find the details by selecting your site and finding the SFTP/SSH section of the Info screen.

We grew our traffic 1,187% with WordPress.
We’ll show you how.

Join 20,000+ others who get our weekly newsletter with insider WordPress tips!

MyKinsta SSH

Just copy this and paste it into the command line.

Once you’ve done that, you will be prompted for your password. Copy that from MyKinsta and you’ll be given access to your server.

You’ll see a screen that looks something like this:

If you’re not with Kinsta hosting, your screen will look a little different, but will still give you access to your server.

How to Use SSH to Interact with Your Site

Download movies online to mac. Now you can start using SSH to interact with your server and your site. There are a number of SSH commands you can use as well as the commands provided by the WordPress Command Line Interface (WP-CLI).

SSH is a very powerful tool and if you aren’t careful, you could break your site. It will let you add and delete files, so if you enter the wrong command, you could lose content or delete all your images, for example. Always use it with caution and make sure you backup your site before using it.

Basic SSH Commands

SSH comes with a range of commands you can use to connect and interact with your server.

Once you’ve looked into your server via the command line, you simply type in SSH commands in the same way you would do if you were using Terminal to interact with your own computer.

Let’s take a look at some of the most useful SSH commands you could start using.

The ls Command

Use the ls command to get a list of the files and directories in your current location. You can add more to the command to get more information:

  • ls -l displays the details of the files, such as size, modified date and time, the owner, and the permissions.
  • ls -a shows hidden files and directories.

The ls command

The cd Command

Use the cd command to change directories. You’ll be taken to the new directory and the command line will indicate where you are:

You can then use ls again to find out what’s in the new directory.

You can use cd to move down more than one directory or to move up or across directories. To go up, enter two dots after cd like this:

And to go to a specific directory, type the full directory path such as:

The mkdir Command

Use the mkdir command to create a new directory. So if I’m in the themes directory, I could create a new directory for a new theme:

The touch Command

Once I’ve created my new directory, I could add a new file to it using the touch command:

The cat Command

To display the contents of a file, use the cat command.

The cat command

The rm Command

Use the rm command to remove a file or folder. Use with caution, as this can’t be undone:

The cp Command

The cp command is used to copy files and folders. You need to provide the name of the file or folder and the location where you want to copy it.

You can also add options at the beginning of the command, but don’t need to. So to copy the footer.php file from one theme to another when you’re in the wp-content directory, you would use this:

Don’t add a name for the destination file. If you do, and there’s already a file with that name at that destination, then the file will be overwritten with the contents of the file you’re copying.

Need a blazing-fast, secure, and developer-friendly hosting? Kinsta is built with WordPress developers in mind and provides plenty of tools through a powerful dashboard. Check out our plans

If you don’t include a filename in the detonation and that file already exists, then you will get an error message and the copy won’t take place.

I’ve already mentioned that there are some optional elements you can add at the beginning of this command. These are:

  • -f: if you don’t have write permission for the destination file, it’ll be deleted and the command will create a new file.
  • -u: copy the source file only if it is newer than the destination file.
  • -n: will not overwrite an existing file.
  • -a: archive the files.
  • -R: for folders only, copy all the files and folders inside that folder.

The mv Command

As an alternative to copying a file, you can move it using the mv command. For this, you just provide the source and destination: there are no options.

This will remove the footer.php file from theme1 and move it to theme2. If you do this with a folder, it will always move the files and folders within that directory too.

You can find information about more SSH commands in the SSH documentation.

Using WP-CLI to Interact with Your Site

Ssh Via Cmd

In addition to the standard SSH commands, WordPress also gives you the WP-CLI interface, which provides even more commands. This includes interacting with files and folders, the admin options, and your database.

With Kinsta, WP-CLI comes with your hosting and you can start using it straight away. If your hosting provider doesn’t give your WP-CLI, you can install it by following the steps in this guide to WP-CLI.

Testing and Troubleshooting Your SSH Connection

Ssh Via Command Prompt

Sometimes you might find that SSH doesn’t behave in the way you want it to. Either you can’t connect, or the command you’ve used doesn’t work in the way you expect.

If that happens, try some of these troubleshooting tips.

If You Can’t Connect Through SSH

How To Ssh Mac

If you can’t connect to your server, take a look at any error messages or prompts that the command line gives you. Sometimes you’ll have to reply to a yes/no prompt or fix a typo in your command.

If that doesn’t work, check that the login credentials you provided are correct. You will be able to get these from the Info page for your site in MyKinsta. Other hosting providers will probably have an SSH section in cPanel or whichever dashboard they’re using.

If you’ve tried again and it still doesn’t work, try resetting your SSH password. Check that your internet connection is working and there isn’t a firewall preventing you from accessing your server. If in doubt, close Terminal or your SSH client down and open it up again.

Log in to your hosting account and check that there aren’t any server issues preventing you from gaining access. If you’re with Kinsta, go to our system status page to find out if anything isn’t working.

If you’re on a public network, it may not allow SSH access to your port. Try testing it with other ports that you know are working.

If all else fails, open a support ticket with your hosting provider who will be able to access logs and work out why you haven’t been able to connect.

If Your SSH Commands Don’t Work as They Should

Another common problem is for an SSH command not to work in the way you expect it to. This is normally due to the command being entered incorrectly.

Here’s an example where I typed is instead of ls :

Inputting a typo in Terminal

Here, I’m presented with an error warning (command not found) so I try again, with the correct command.

Sometimes you might type the command correctly but get the parameters wrong. If this is the case, check the SSH documentation for SSH commands and the WP-CLI documentation for WP-CLI commands.

If your SSH commands don’t work because the connection isn’t working, you will see an error message telling you this. The command line constantly provides you with information on what’s going on, which is one of its benefits. In fact, it often gives you more and clearer information that a graphical interface.

How to Generate a New SSH Key Pair for Extra Security

Generating an SSH key pair adds an extra layer of security when compared to using your username and password to connect to SSH. You do it from within the Terminal or your SSH client. Here’s how.

Generating a key pair involves three steps:

  1. Generate the key pair in Terminal or in your SSH client.
  2. Add the key pair to your hosting account – in MyKinsta you do this via the User Settings screens.
  3. Connect to your server in Terminal or your SSH client using the key pair.

You can find full instructions on doing this in our guide to generating SSH key pairs for macOS, Linux, and Windows.

Summary

Using SSH to connect to your server and your WordPress site will make you more efficient than relying on the WordPress admin interface, FTP, and even phpMyAdmin.

Ssh Via Web

Follow the steps above to connect to your server via SSH and you’ll find you can do more on your site without having to switch between applications or browser windows.

Now it’s your turn: what’s your preferred terminal command you use on a daily basis? Let us know in the comments!

If you enjoyed this article, then you’ll love Kinsta’s WordPress hosting platform. Turbocharge your website and get 24/7 support from our veteran WordPress team. Our Google Cloud powered infrastructure focuses on auto-scaling, performance, and security. Let us show you the Kinsta difference! Check out our plans

Feature

Flywheel is excited to help you manage your sites more efficiently with our new SSH gateway! Our customers now have direct access to their sites via the command line. This opens the door to many new site management capabilities by using tools like WP-CLI for streamlined WordPress management, MySQL for importing and exporting databases, and rsync for moving files quicker and aiding in deployment workflows.

We approached SSH the same way we reimagined SFTP for modern web design workflows. All your sites are in one place with one key-based authentication and SSH also allows you to connect directly to each individual site.

Setting up SSH

To connect to SSH, head over to the new SSH tab under your Account and add a public SSH key. For help generating a key, check out our article on SSH Key Management.

You only need one public key to connect, but if you’re connecting to SSH on multiple machines, for example, you’re free to add as many as you want. Public keys also must be unique and can’t be shared between Flywheel users.

Connecting to SSH

Once your public key has been added, you can now connect to SSH via the command line. Using your terminal program of choice (like Terminal or iTerm for Mac, or PuTTY for Windows), you can view a list of all sites you have access to or connect directly to one of them. For more information on connecting to your sites and what you can do after, check out our article on accessing your site with SSH for more details.

Using SSH

Once connected to the SSH gateway, the fun begins! There are many different things you can do inside the terminal, but here are a few articles on different workflows that take advantage of our new SSH gateway:

Transfer Files Via Ssh

We’re so excited about the flexibility and customization this provides for your everyday workflow. If you have any questions about Flywheel’s SSH or getting started with this feature, please reach out to our team.

Coments are closed
Scroll to top