Perpetual Screen Part Deux

So, I’ve figured out how to add in a “fail-safe” to the perpetual screen, so that if you want to ssh without starting screen you can.  And it’s pretty easy.  First add the following to your sshd_config and restart ssh

AcceptEnv NO_SCREEN

Then add the following to the bottom of you .bashrc:   (Note: I named my screen ‘main’ you can name yours whatever you want)

NO_SCREEN=`echo "."$NO_SCREEN`
# Hack to get around if the variable is not set

if [ $TERM = "screen" ]
# If we are already in a screen do nothing
then
     echo -n ""
elif [ $TERM = "dumb" ]
# If we are using scp do nothing
then
     echo -n ""
elif [ $NO_SCREEN = ".true" ]
# Our fail safe to ssh w/o screen
then
     echo -n ""
else
# Startup screen
     screen -Rd main && exit
fi

Then, you can either ssh like normal to start the screen, or do the following to login without screen starting

export NO_SCREEN=”true”

ssh -o “SendEnv NO_SCREEN” [email protected]

Works like a champ

This entry was posted in Computers, Linux and tagged , . Bookmark the permalink.