Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 want to add alias that ssh to remote machine, run few commands on it and then give me back the control to continue using this machine.

when I'm trying to run:

ssh machine_ip 'command'

the SSH shell is closing after executing the command. and when I'm trying to run:

ssh machine ip ; command

the command is executing on my local machine after i exit the remote machine.

can you please help ?

Thanks, Guy Ergas

share|improve this question

migrated from Nov 7 '12 at 18:49

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

do not forget to share your public key to prevent the password prompt.ssh-copy-id remote-user@remote-host – derlinuxer Nov 7 '12 at 12:41

Try this:

ssh -t machine "echo hello; echo world; /bin/bash --login"

The -t option forces ssh to allocate a pseudo-terminal. Separate your commands with a semicolon and at the end of the list execute the shell you want to start e.g. /bin/bash.

share|improve this answer

Your Answer


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