Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I access a Beowulf cluster which only allows local connections when I am at work. To work on the cluster from home, I login to an onsite ssh server then run a simple ssh script, to login to the cluster. What i want to do is have 1 script I can run at home to link my up to the on site ssh server, then onto the cluster. My ssh sever that accesses the cluster is Ubuntu 13.04, and my home client computer is Ubuntu 12.04

how can i tell ssh to execute a script once it logs in?

share|improve this question
up vote 1 down vote accepted

ssh allows by default executing commands, e.g.

ssh <host> <command>


ssh <host> '<command1>; <command2>'

In your case, you will probably need to specify -t to force tty allocation on the middle-server. So try something like:

ssh -t <your gateway> '<script call>'
share|improve this answer
Ah beautiful! This works. Thank you so much! – j0h Jan 4 '14 at 22:27

Your Answer


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.