I found myself setting up bash aliases that auto log me into my servers without having to type in a port number or password, but always found myself typing screen -x after I log in. I wanted a way to automatically queue a command after the SSH was established.
Sometimes, in spotty areas of connections, I have to do it *a lot*.
Passing in screen -x after the ssh returns an error that a terminal must be connected…
The solution is to use the -t flag
-t Force pseudo-tty allocation. This can be used to execute arbi-
trary screen-based programs on a remote machine, which can be
very useful, e.g., when implementing menu services. Multiple -t
options force tty allocation, even if ssh has no local tty.
ssh email@example.com -p 3298 -t "screen -x"