Bash / bash-alias / SSH — Automatically screen -x after logging in


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 -p 3298 -t "screen -x" 

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s