The simple answer is

ssh username@hostname

Enter your password and you are set. My problem is that I wish to connect to a computer in my university. There are several machines which everyone can access but before doing so we have to go through the login machine. So say the name of the login machine is login.school.edu

Then I would do

ssh login.school.edu

From there then I would ssh to one of the several machine names

ssh ld00

They have 112 machines, so I can do ld00 through ld112. The reason I'm asking this is because I want to run the Mathematica Kernel in one of these machines but in the Kernel configuration it asks for the hostname. The hostname cannot be the login machine because this machine does not have Mathematica installed and this machine wasn't meant for computations. Any way I can bypass this?


So it seems that those machines are not public in the internet. Now that I'm in the deparment I connected to the network and now I can do a simple

ssh username@hostname

The administrator of the machines did say something interesting:

I do not know what SSH implementation is currently part of MacOS. Under OpenSSH (used on Linux machines) it is theoretically possible to make creative use of the ProxyCommand directive to make it appear as if those hosts are directly available to SSH. I cannot tell you how to do this, however; I've only seen mention of it.

So, does anyone know how to do this so that I can connect to the kernel from outside the school?

  • 3
    $\begingroup$ Math failed: ld00 to ld112 , there are 113 machines. $\endgroup$
    – Shivan Raptor
    May 3, 2012 at 6:53
  • $\begingroup$ @ShivanRaptor, lol, yes ... $\endgroup$
    – jmlopez
    May 3, 2012 at 6:55
  • $\begingroup$ Any reason why you didn't ask this over at Mathematica? $\endgroup$
    – rcollyer
    May 3, 2012 at 15:01
  • $\begingroup$ @rcollyer, I thought about it, but even thought I want to use this information to apply it to Mathematica this seems to be more general. I have been wanting to use this also with python and other scripts. $\endgroup$
    – jmlopez
    May 3, 2012 at 16:16
  • $\begingroup$ While more general, the answer will be environment specific (and yes, I'm counting MMA as an environment). $\endgroup$
    – rcollyer
    May 3, 2012 at 16:28

1 Answer 1


From your update, your situation is very similar to mine, where I can connect to hostA through the internet, but to hostB only via hostA. Here is the pared down settings from my ~/.ssh/config that you can adapt to your machines:

Host hostA
    HostName hostA.school.edu
    User rm
    ForwardX11 yes
    ForwardX11Trusted yes       
    ControlMaster auto
    ControlPath ~/.ssh/control:%h:%p:%r

Host hostB
    Hostname hostB.school.edu
    User rm
    ProxyCommand ssh -T -a hostA nc %h %p

Here, using ControlMaster and ControlPath lets you tunnel all subsequent connections to hostA via an existing connection. So this means that you need to have only 1 open connection (need password, if not using keys) and you needn't enter your password again as long as that session is alive (extremely convenient and useful in general!).

The second, using ProxyCommand allows you to login to the second through the first. So if you have one open connection to hostA, you can then simply ssh hostB on your local machine and the connection will automatically be routed through hostA. Now if you didn't set up ControlMaster and ControlPath, you'll have to enter 2 passwords — one for hostA and another for hostB.

  • $\begingroup$ Thanks, this works very nicely with ssh. Now I can connect directly with just one command. One more problem though, and this about the Kernel configuration. When I'm in school I can put the hostname and it works. But now that I'm away it doesn't work. Is there a way to let Mathematica know of the .ssh/config file? $\endgroup$
    – jmlopez
    May 4, 2012 at 1:36
  • $\begingroup$ hmm... not sure I follow fully. You said your mma installation is on the ldXYZ machines, right? So shouldn't you just set that as the hostname in your mma kernel configuration file? $\endgroup$
    – rm -rf
    May 4, 2012 at 1:45
  • $\begingroup$ Yes, all the ldXYZ machines have mma. If I log in them and type hostname then I get the full hostname which you need when you want to configure another kernel. See this: wolfram.com/broadcast/screencasts/howtoconnecttoaremotekernel/… . I followed those instructions when connected directly to the network and it works fine. But now that I'm away I cannot seem to make it work. You answer works with ssh now, but I'm not sure com.wolfram.WolframSSH.WolframSSH knows how to do this. $\endgroup$
    – jmlopez
    May 4, 2012 at 1:50
  • $\begingroup$ @jmlopez In Preferences > Parallel > Remote Kernels > Add Host, I see an option to enter a custom command. Now you can use the -F flag in ssh to specify a config file. You can specify the location to your config file to make sure that mma knows about it. I don't have a remote mma kernel to actually check this out, but I'm pretty sure it should work. Could you please try it and if it does, I'll update my answer with the info $\endgroup$
    – rm -rf
    May 4, 2012 at 2:58
  • $\begingroup$ I'm having problems, We can also put a custom command in Evaluation > Kernel Configuration Options > Add then after setting Remote Machine then we can put a custom command. But, I don't quite understand the " and ` so I don't know where to put the F flag. $\endgroup$
    – jmlopez
    May 4, 2012 at 3:45

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.