I have a problem concerning the connection to a remote kernel via ssh on a vpn. I found a working configuration in this question:

Connection to remote kernel can not be established - No specific error shown

However, I use Windows 7 as my client and therefore cannot run the same command as the kind sir there provided in his answer:

ssh -R 31415: -R 31416: [email protected] "dbus-launch --exit-with-session /usr/local/bin/math -mathlink -LinkMode Connect ..." because Windows does not have openssh built in but instead adapted that command to use the installed openSSH version of cygwin:

C:\Users\<username>\bin\bash --login -i -c "ssh -v -i /cygdrive/c/Users/<username>/Path/to/private/key [email protected] /usr/local/bin/math -mathlink -LinkMode Connect ..."

This command DOES work if I run it directly in the windows console, the connection with the private key gets established, but when I try this same command in the remote kernel configuration the error in the title occurs without more specific troubleshooting help. Also the other question dealing with that error I could find had passphrase/private key problems and couldn't even connect via the console.

Upon inspecting the differences of the openssh version I noticed my client in cygwin uses 6.1p1 while the server uses 5.5p1. I tried installing a current openssh version on the Debian 6.0 server but the last officially supported and maintained one for that OS version is 5.5p1 and it doesn't seem such a good idea to me to upgrade to a not officially supported version. When trying to install an older version in cygwin, I cannot even select an older openssh version when running the cygwin setup again and selecting a cygwin packages mirror. So I searched for ~10 alternative mirrors that provide older openssh packages, but they all seem to lack a "setup.ini" file so no connection could be established.

I ask for help here because this seems to be a Mathematica specific problem, not a ssh related one..other clients with Mac OS X 10.8 can connect to the server using the same private key fine..

Does anyone have a similar setup and could give me a hint what might cause the error? Is there something I did not see in the remote kernel configuration? I use Mathematica 8.0.4, Windows 7 64bit client with openssh-6.1p1, Debian 6.0 server with openssh-5.5p1, cygwin 1.7.17.

Thank you!

Update: In the meantime I found someone with nearly the same problem, however 3 years ago and with no answer (i hope you don't mind links to other platforms: https://groups.google.com/forum/#!topic/comp.soft-sys.math.mathematica/K-Z3xbQNzbY

  • $\begingroup$ Entering things into that "custom launch command" box seems to be a bit unreliable in my experience. You might instead try assigning your launch command (as a string) to the variable SubKernels`RemoteKernels`$RemoteCommand--then you just need to tick the box when adding a kernel to have this remembered. $\endgroup$ Commented Mar 14, 2013 at 4:45
  • $\begingroup$ thanks Oleksandr R. , I tried your suggestion, I typed this command SubKernelsRemoteKernels$RemoteCommand = "C:\Users\<user>\bin\bash--login-i-c \"ssh -v -i \ /cygdrive/c/Users/<user>/path/to/key [email protected] /usr/local/bin/math -mathlink -LinkMode Connect -LinkProtocol TCPIP -LinkName linkname` -LinkHost\""` into an empty notebook and run it, just to test the connection, however, still no success, the same error persists..do you have any other suggestions? $\endgroup$
    – hreimer
    Commented Mar 16, 2013 at 23:33
  • $\begingroup$ Don't forget that \ also needs to be escaped (as \\) in strings. Other than that, I'm not quite sure--I don't have this same configuration, so unfortunately I can't tell you what's likely to work. If you still have trouble, perhaps you might like to try using ssh port forwarding to set up the connection ahead of time? $\endgroup$ Commented Mar 17, 2013 at 5:43
  • $\begingroup$ oh, of course, I escaped it correctly, just copied it from somewhere else unescaped..unfortunately ssh portforwading also did not do the trick..if you happen to have any more hints I would be glad to try them, thanks for your effort $\endgroup$
    – hreimer
    Commented Mar 18, 2013 at 21:21
  • $\begingroup$ Here is a solution that uses SSH and works well. $\endgroup$ Commented Feb 3, 2016 at 15:15

4 Answers 4


This is what I did (using mathematica 9.0.1; remote RHEL linux server for running kernels; local workstation windows 7 64bit):

On the remote kernels-tab I added the hostname of the server. Then I checked the 'Use custom launch command' and added the following:

plink -ssh -batch -l  `3`  `1`  "math -mathlink -linkmode Connect `4` -linkname '`2`' -subkernel -noinit  >& /dev/null &“

To be able to run plink, you should install the putty package and add the installation directory to the system path. The ampersand at the end is required because the math command should be run as a background process and the connection should terminate. Otherwise the command window will stay open and mathematica aborts the session after a while.

Also, to make this work you should disable (or configure) the firewall on the local workstation to allow inbound connections from the remote server. Mathematica will use random port numbers (specified in `2`). The remote server only requires outbound connections.

If your local login name is not the same as your server account, you should replace `3` with your server login name.

To prevent entering a passwords when starting remote kernels, you could use a public key pair (using Pageant for example).

If all is setup properly, you can click the 'parallel kernel status' button and launch all kernels.

On linux systems you can rely on the default ssh implementation:

ssh -x -f -l `3` `1` math -mathlink -linkmode Connect `4` -linkname '`2`' -subkernel –noinit

The -f switch tell ssh to enter background mode before running the command line, so no trailing ampersand is required here.

To summarize the `#` parameters:

`1` = hostname as specified in dialog
`2` = connect string format: port1@ip-workstation,port2@ip-workstation
`3` = username on current workstation
`4` = -linkprotocol TCPIP (i.e. additional parameters)

That should do...

  • 1
    $\begingroup$ Welcome at Mathematica.SE Paul! If you enter a name in your profile your avatar won't have a prisoner number anymore and you don't have to sign your post (which, btw, isn't a custom here and is specifically mentioned in the faq) $\endgroup$ Commented Jun 19, 2013 at 12:57
  • $\begingroup$ are you really work out this? since I have failed when follow your steps $\endgroup$
    – van abel
    Commented Apr 12, 2014 at 14:52

This is not the desired solution, but it is what I ended up doing: I finally gave up on trying to access a remote math kernel under Windows 7 and used a Ubuntu 12.04 image in VMWare which worked as expected.

Since the guy in the last link, who had the same problem 2 years ago, also couldn't make it work and eventually gave up I assume it's some kind of error in the Windows-Package of Mathematica or Windows itself. I can't believe though there are no users who found out how to run it..

Should somebody be able to provide a real solution to that problem I will remove that answer..


Modified upon this answer I managed to connect to the remote kernels. The client laptop is running Mathematica 11.2 on Windows, and remote kernel Mathematica 11.2 on RHEL 7. Here is what I did:

Evaluation -> Kernel Config Options -> Add Advanced Options -> Arguments to MLOpen:

-LinkMode Listen -LinkProtocol TCPIP -LinkOptions MLDontInteract

Advanced Options -> Shell command to launch kernel:

C:\\cygwin64\\bin\\ssh [email protected] "math -mathlink -linkmode Connect -linkprotocol TCPIP -linkname `linkname` -noinit &< /dev/null&"

(note: no -subkernel)

Then Evaluation -> Notebook Kernel -> the_new_created_one

Try to evaluate things like 1+1 or $Version to see if it works. It works for me like a charm and hopefully for you too.

PS. I have been wrestling with this for years, since mathematica 8 or 9. I'm glad it finally works.

  • $\begingroup$ By the way, when I try to connect to the remote kernel it does take a long time, around 1-2 minutes. I have no idea why it takes that long but once it's connected everything is pretty smooth. Much better experience than ssh -X or -Y graphically forwarding the whole GUI or invoke ParallelTable/ParallelDo/ParallelEvaluate every time. $\endgroup$
    – Boson Bear
    Commented May 7, 2018 at 21:44

Try to delete the know_hosts file in C:\Users\user.ssh and re-run. I have solved this problem several times doing this. I am not really sure why it works but it does.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.