ssh with command…Plus the shell

前端 未结 5 2190
别跟我提以往
别跟我提以往 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:56

    Put something like this at the end of the script you want to run:

    bash -li
    

    That starts Bash as an interactive login shell. It's not perfect, since you'll be missing out on things like TERM forwarding, but it might be adequate to your needs.

    If it isn't sufficient, I'd just make two separate ssh calls, one to run the script and another to log me in.

提交回复
热议问题