I use tmux on a jump box. I'm trying to automate certain common scenarios. How can I do the following?:
- create new window
- ssh to remote host
- execute some commands on remote host (i.e.: cd and dot-slash something)
- stay logged in
I can do it with ssh:
ssh -t root@2.158.0.10 "cd ~adarias/duncans/ServiceAgent/tests; bash -l -c 'mocha config_tests.js'; bash -l"
but not with tmux new-window:
tmux new-window -t mosdev -d -n 'debug & test' 'ssh -T root@2.158.0.10 < .mosdev/scripts/test_config.sh; bash -l'
I put the shell commands in a separate file because I was having issues with nested quotes which I couldn't figure out how to work around.
.mosdev/scripts/test_config.sh:
#!/bin/bash
cd ~adarias/duncans/ServiceAgent/tests; bash -l -c 'mocha config_tests.js'; bash -l
The ssh session to the remote host doesn't stay open. Although the new window does, I get dropped back at a prompt on the jump box.
So, what am I missing here? How can I get that session to stay open?