Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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?

Update:

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?

share|improve this question
2  
Math failed: ld00 to ld112 , there are 113 machines. –  Shivan Raptor May 3 '12 at 6:53
    
@ShivanRaptor, lol, yes ... –  jmlopez May 3 '12 at 6:55
    
Any reason why you didn't ask this over at Mathematica? –  rcollyer May 3 '12 at 15:01
    
@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. –  jmlopez May 3 '12 at 16:16
    
While more general, the answer will be environment specific (and yes, I'm counting MMA as an environment). –  rcollyer May 3 '12 at 16:28
show 6 more comments

migrated from stackoverflow.com May 3 '12 at 19:22

This question came from our site for professional and enthusiast programmers.

1 Answer

up vote 3 down vote accepted

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.

share|improve this answer
    
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? –  jmlopez May 4 '12 at 1:36
    
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? –  rm -rf May 4 '12 at 1:45
    
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. –  jmlopez May 4 '12 at 1:50
    
@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 –  rm -rf May 4 '12 at 2:58
    
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. –  jmlopez May 4 '12 at 3:45
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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