What this tutorial is about
This tutorial describes how to make use of the PyCharm built-in SSH terminal and remote tools.
What this tutorial is not about
SSH basics are out of scope of this tutorial.
Before you start, make sure that:
- You are working with PyCharm 3.0 or higher.
- You have access to a SSH server.
Working with SSH client
Let's see how we can work with the PyCharm's built-in SSH client.
On the main menu, choose Tools | Start SSH Session..., and then click Edit credentials:
Provide connection information
In the SSH Session dialog box, specify the connection information: host (local or remote), port, login name and password:
Lo and behold!
After clicking OK, the SSH session starts in the dedicated tab of the Teminal tool window:
What can we do in a SSH session?
As usual for an interactive session... run commands remotely, copy and paste, scroll through the history of commands using up and down arrow keys.
Working with remote SSH external tool
Let's define an external tool that will run a command over SSH, for example, show a calendar.
Configuring a SSH external tool
Open the Settings/Preferences dialog ( on the main toolbar), and under the IDE Settings, select the page Remote SSH External Tool. Click to create a new remote tool, and in the Create Tool dialog specify the new tool settings:
- Name help specifying some visible name of the new tool. The next two fields are optional:
- In the Description field you can type some meaningful description.
- Group with the specified name will be created in the Tools menu, and the new SSH external tool will be placed under this group.
- In the Show in area specify where do you want to see the new tool. In this case, select the check box Main Menu only.
- In the Connection settings area click the radio button Select server on every run. It means that every time you want to run this external tool, you will have to specify the connection settings.
- Finally, in the Tool settings area, specify the tool to be execured remotely. In the screenshot below we are running a bash command; parameters and working directory are optional. We can also make use of macros to inject the current command name.
For the detailed description of controls, refer to the product documentation
Launching SSH external tool
Once a tool has been set up, it will be shown in the menus selected earlier. In this case, this is the Tools menu that will display the newly created remote SSH external tool under the group, defined in the previous section:
Let's choose this command and see what happens. First of all, you are suggested to choose the server to connect to:
Having chosen Edit credentials, specify the connection settings:
And finally, you see the calendar! Here it is:
Unlike SSH session that runs in a Terminal tool window, the SSH external tool is launched in the Run tool window:
What has been done in this tutorial?
- You have launched an interactive SSH session.
- You have defined a SSH external tool and launched it.