|This tutorial describes how to make use of the PhpStorm built-in SSH terminal and remote tools.|
- Working with SSH client
- Working with remote SSH external tools
Let's see how we can work with PhpStorm's built-in SSH client.
From the Tools | Start SSH session... menu, we can connect to any SSH server, whether your local machine or a remote host.
Next, we have to provide connection information. We have to provide:
- Host, the host to connect to. This can be a local or remote host.
- Port, the SSH port to use
- User name, the username to connect with (optionally Login as anonymous can be enabled)
- Auth type, to select between traditional username/password authentication or SSH key authentication.
- Password (or Private Key file), the password or private key file to use for authentication.
After we click OK, PhpStorm will connect to the remote SSH server and show us a terminal to work with.
In the SSH terminal, we can run commands remotely as well as copy/paste data back and forth.
When building applications as a team and working on a dedicated remote development environment, it can be useful to invoke remote commands over SSH. For example, after deploying we may want to run a shell script which flushes the current cache, or a script which sets up a new virtual machine. In PhpStorm, we can make use of remote SSH external tools that can be added to the Tools menu in our IDE.
From the settings under IDE Settings | Remote SSH External Tools we can configure remote SSH external tools.
Clicking the Add button provides us an interface in which we can set up parameters for the external tool to run:
- Name, Group and Description allow us to specify a meaningful name to be used for the external tool.
- Under Options, we can specify what we want to see when the remote SSH external tool is run. For example, we can Synchronize files after execution to automatically download files that have been changed on the remote host. If our tool was to minimize CSS, for example, we could download the minified CSS back to our developer box.
- Show in allows us to specify in which menus we want to see the tool mentioned. By default, all menus are selected but we can limit this to the main menu or another menu.
- Connection settings allows us to specify the server on which the tool should be invoked.
- Under Tool settings we cans pecify the tool to run remotely. In the screenshot below we are running a remote PHP script by specifying the program, parameters and optionally a working directory. We can also make use of macros to inject the current script name and so on.
Once a tool has been set up, it will be shown in the menus selected earlier. The Tools menu will display our newly created remote SSH external tool.
When invoking the tool, we have to specify connection details to connect to the remote server.
After clicking OK, PhpStorm will connect to the remote SSH server and run the configured remote SSH external tool. If configured in the options before, it will show the tool's output in a tool window in our IDE.