How can I run a shell script on connection in CLion Full Remote mode?

Answered

I have a central server that handles all software builds and testing. Each project on that server has a Docker container with all of the build dependencies (compiler, etc.), and a script that starts the container (if it's not already running) and then starts a new shell session inside the container. All development needs to happen inside that shell session. Because there are many containers (one per project), it is not feasible to have an sshd process running in each one (each sshd would need to be configured, audited, and assigned a port).

Is there any way to set up a CLion full-remote development server (see https://www.jetbrains.com/help/clion/remote-projects-support.html) so that whenever it makes a new ssh connection it immediately runs a shell command? That would allow it to connect to the server, then jump right into the correct container.

1 comment
Comment actions Permalink

Hello!

>That would allow it to connect to the server, then jump right into the correct container.

For such scenario we usually suggest the following: 

You can try to connect to the docker container using port forwarding through a jump server (your PC -> remote server -> docker container). In order to do this you need to setup your .ssh/config file to allow this using ProxyCommand and then in CLion create a remote toolchain (https://www.jetbrains.com/help/clion/remote-projects-support.html#remote-toolchain) with the "OpenSSH config and authentication agent" authentication type. OpenSSH config with ProxyCommanddirective is supported, so it should work.

>Is there any way to set up a CLion full-remote development server so that whenever it makes a new ssh connection it immediately runs a shell command?

There is no way to do that automatically. 

0

Please sign in to leave a comment.