ssh with command…Plus the shell

前端 未结 5 2216
别跟我提以往
别跟我提以往 2020-12-14 10:08

I\'d like a command that ssh\'es into a machine, runs a command (cd or execute a script or su), and then gives me the shell. Passing a command to ssh seems to always exit.

5条回答
  •  青春惊慌失措
    2020-12-14 10:38

    How about

        ssh me@machine ./executeMyScript '&&' bash -i
    

    You have to quote the && so it will be passed to the remote machine instead of swallowed by the local shell.

    Quote a ';' character and you can change your start directory, too:

        ssh me@machine ./executeMyScript '&&' cd /developmentDirectory ';' bash -i
    

提交回复
热议问题