# Remote Mathkernel: SSH encountered a networking error while launching kernel Error code = 1

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:10.8.0.6:31415 -R 31416:10.8.0.6:31416 user@10.8.0.1 "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 user@10.8.0.1 /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

-
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 SubKernelsRemoteKernels$RemoteCommand--then you just need to tick the box when adding a kernel to have this remembered. – Oleksandr R. Mar 14 '13 at 4:45 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 user@10.8.0.1 /usr/local/bin/math -mathlink -LinkMode Connect -LinkProtocol TCPIP -LinkName linkname -LinkHost 10.8.0.6\"" 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? – hajn Mar 16 '13 at 23:33
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? – Oleksandr R. Mar 17 '13 at 5:43
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 – hajn Mar 18 '13 at 21:21
Here is a solution that uses SSH and works well. – The Quantum Physicist Feb 3 at 15:15

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...

-
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) – Sjoerd C. de Vries Jun 19 '13 at 12:57
are you really work out this? since I have failed when follow your steps – van abel Apr 12 '14 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..

-

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.

-