1

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

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

1 Answer 1

2

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.

You must log in to answer this question.