PyCharm 2022.2 Help

Configure an interpreter using SSH

Prerequisites

  • An ssh server should run on a remote host, since PyCharm runs remote interpreters via ssh-sessions.

  • If you want to copy your sources to a remote computer, create a deployment configuration, as described in the section Create a remote server configuration.

Configuring remote Python interpreter via SSH credentials

Create a new remote Python interpreter via SSH credentials

  1. Ensure that you have downloaded and installed Python on your computer.

  2. Do one of the following:

    • Click the Python Interpreter selector and choose Add New Interpreter.

    • Press Ctrl+Alt+S to open the project Settings/Preferences and go to Project: <project name> | Python Interpreter. Click the Add Interpreter link next to the list of the available interpreters.

  3. Select On SSH from the list of the available interpreter types.

    Adding SSH interpreters
  4. Select an option to create a new SSH configuration, then specify server information (host, port, and username).

    adding an interpreter via SSH
  5. In the next dialog window, provide the authentication details to connect to the target server.

    specifying authentication details

    Select Password or Key pair (OpenSSH or PuTTY) and enter your password or passphrase. If Key pair (OpenSSH or PuTTY) is selected, specify:

    • Private key: location of the file with a private key

    • Passphrase: similar to a password, it serves to encrypt the private key.

    Click Next to proceed.

  6. Wait until PyCharm completes the introspection of the SSH server.

    SSH server introspection
  7. In the next dialog, you can select a type of Python environment to configure on the SSH server.

    Selecting a Python environment

    You can select a new or existing venv or use a System interpreter.

    You can configure the path mappings between your local project and the server. To do that, click the Browse icon in the Sync folders field and enter the path to the local project folder and the path to the folder on the remote server.

    Click Create to complete adding an interpreter.

Create a new remote Python interpreter using an SSH configuration

  1. Ensure that you have downloaded and installed Python on your computer.

  2. Do one of the following:

    • Click the Python Interpreter selector and choose Add New Interpreter.

    • Press Ctrl+Alt+S to open the project Settings/Preferences and go to Project: <project name> | Python Interpreter. Click the Add Interpreter link next to the list of the available interpreters.

  3. Select On SSH from the list of the available interpreter types.

    Adding SSH interpreters
  4. Select an option to use an existing SSH configuration, then select the configuration from the list.

    List of existing SSH configurations

    Alternatively, you can create a new SSH configuration from this dialog. Click Browse button next to the list of configurations:

    Add new SSH configuration

    Click new configuration, disable the Visible only for this project checkbox, and fill the required fields:

    Adding new SSH configuration

    Once done, the newly created SSH configuration will appear in the list of available configurations. It will also become available in the SSH Deployment Configurations settings. Click Next to proceed:

    Connecting to SSH server
  5. Wait until PyCharm completes the introspection of the SSH server.

    SSH server introspection
  6. In the next dialog, you can select a type of Python environment to configure on the SSH server.

    Selecting a Python environment

    You can select a new or existing venv or use a System interpreter.

    You can configure the path mappings between your local project and the server. To do that, click the Browse icon in the Sync folders field and enter the path to the local project folder and the path to the folder on the remote server.

    Click Create to complete adding an interpreter.

  7. When you change an SSH interpreter, you might need to synchronize the local content with the target server. Mind a notification balloon in the lower-right corner:

    Sync local files with the deployment server
    You can choose to perform one of the following actions:

    • Auto-upload files to the server

    • Synchronize files and then enable auto-uploading

Last modified: 19 September 2022