screen more and more, but this night I ran into a problem I hadn’t anticipated. I was trying to establish SSH sessions inside “pre-created” windows (using a specific screen profile). Now I wanted to automatically call an initial command once the SSH connection would be established.
screen -t machine ssh machine worked fine (and started the remote shell), but once I used any command (
screen -t machine ssh machine command), the remote terminal wouldn’t echo (no prompt, for example) but it would show black/white output of commands I’d run. So clearly the command I had invoked on the remote end was being executed, just something was wrong with the terminal type (among other things).
The solution was interesting though. By adding the
-t option I would force SSH to allocate a pty and suddenly it worked.
screen -t machine ssh -t machine command