Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
    
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
add comment

migrated from stackoverflow.com Nov 7 '12 at 18:49

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

1 Answer

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
add comment

Your Answer

 
discard

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