CLion 2020.2 Help

Full remote mode

With full remote mode, you can work on a macOS, Linux, or Windows desktop targeting a remote Linux machine connected via SSH. You can choose any Linux-based target, including embedded systems on single-board computers like Raspberry Pi. Also, your program can be launched on a cloud platform or, for example, inside a Docker container.

For remote development, the CLion instance runs locally, and your source files are also placed on the local client, with automatic synchronization to the remote host. On the remote host side, CLion performs compilation and build using host compilers and CMake, uses host GDB for debug, and runs the application on the remote target.

When working on a Windows client, keep in mind the following:

  • Due to the IntelliJ platform issue, you need to set the property value in the file (to access the property file, select Help | Edit Custom Properties... on the main menu), then restart CLion with cache reset (File | Invalidate Caches / Restart...).

  • For files synchronization on Windows, CLion relies on its own Remote Host Access and compression on the host side using the tar utility. This mechanism causes the synchronization to perform slower than rsync on macOS and Linux.

    Create a toolchain with remote credentials

    1. Go to Settings / Preferences | Build, Execution, Deployment | Toolchains and select Remote Host from the list of toolchains or click plus icon and select Remote Host from the drop-down menu to create a new toolchain.

    2. Click next to the Credentials field. In the dialog that opens, create an SSH configuration and provide the credentials for accessing you remote machine. Existing SSH configurations are available from the drop-down list.

      credentials to access the remote host
    3. After establishing the connection, CLion attempts to detect the tools in default remote locations /usr/bin/cmake and /usr/bin/gdb (or using the full paths, if you have provided manually). When the checks finish successfully, the toolchain is ready for use:

      remote toolchain configured successfully

    4. You can make the newly created toolchain the default one (for this, move it to the top of the toolchains list by clicking move upmove down). When set as default, the remote toolchain is used for all the projects you create and open in CLion.

      Note that if you set the remote toolchain as default, the default CMake profile will connect to it automatically, so you do not need to configure a separate CMake profile for it.

    Create the corresponding CMake profile

    • Go to Settings / Preferences | Build, Execution, Deployment | CMake, click plus icon to create a new CMake profile, and connect it to your remote toolchain using the Toolchain field:

      CMake profile for the remote toolchain

    Check and adjust the deployment configuration

    • When you create a connection entity for the remote toolchain, CLion puts it in the list of server access configurations in Settings / Preferences | Build, Execution, Deployment | Deployment.

      CLion automatically configures the paths for your project code synchronization. Use the Mappings tab to change the default mappings (for example, to set a particular remote directory for the copied sources instead of the default tmp folder):

      path mapping for file synchronization

    • You can monitor the synchronization process in the File Transfer tool window (View | Tool Windows | File Transfer):

      file transfer tool window

    Resync header search paths

    • To resolve your code correctly, CLion synchronizes header search paths with all the content from the remote machine to the local client. For example, even though standard library headers are taken from the target, you can navigate to them as if you were working locally in the CLion editor.

      However, header search paths synchronization can be time-consuming, so CLion performs it automatically only upon the initial file transfer. After that, it is not triggered by CMake reloads. So every time you switch the compiler or make changes in your project dependencies, make sure to update header search paths manually by calling Tools | Resync with Remote Hosts.

      You can also switch to automatic synchronization: set the clion.remote.resync.system.cache key in the Registry (go to Help | Find Action or press Ctrl+Shift+A, type Registry, and search for the key by name).

    Build, run, debug

    Now that you have a remote toolchain and the corresponding CMake profile configured, you can build, run, and debug your application and tests in the completely remote way by selecting the proper CMake profile in the Run/Debug configuration switcher:

    cmake profile for remote

    Also, you can use the remote SSH terminal and run remote external tools as a Before launch step of your Run/Debug configuration.

    Below you can find a demo showing how the application output changes depending on the OS that it runs on. Having macOS as a local system, we connect remotely to the Ubuntu target and check the OS name. In this example, code highlighting depends on the OS identifier, so when we switch the CMake profile or resolve context, CLion highlights the corresponding code branch:

    choose build configuration for remote run

      Enable IPv6 support

      • To connect to IPv6 networks, you need to make adjustments in CLion JVM options:

        1. Run Help | Edit Custom VM Options from the main menu. In the *.vmoptions file that opens, delete the line and add the following lines:

        2. Restart CLion.

      • In order to use hostnames instead of raw addresses, open C:\Windows\System32\Drivers\etc\hosts as Administrator on Windows or /etc/hosts as superuser on macOS/Linux and map the required addresses to the corresponding hostnames.

        Each address should be placed on a separate line, followed by at least one whitespace and a list of whitespace-separated hostnames, for example:

        f381::171d:c61c:c7f3:3a56 f381::171d:c61c:c7f3:3a26%en0

      • On macOS, you also need to specify the list of the banned network interfaces:

        1. Go to Help | Find Action and type Registry.

        2. Find the deployment.macOs.bannedInterfaces key and set a comma-separated list of the interfaces to be banned, for example awdl0,bridge0,en1,en2,lo0,p2p0,utun0,utun1.

      Last modified: 01 December 2020