Ivor O’Connor

September 30, 2012

Autossh, screen, and coffee shops

Filed under: Uncategorized — ioconnor @ 1:35 am

The coffee shop here has a horrible internet connection. Fortunately though there are some tools to help.

First there’s “autossh” instead of “ssh”. With autossh you don’t have to keep retyping “ssh ….@….” each time the connection goes out.

Secondly there is “screen”. I don’t know how people lived without screen. It allows for multiple shells with only one connection. So you can have your sql cli shell, your vi shell, your tail on the error log shell, and a shell where you execute the commands. Then bounce or go directly to the shell you want. (I sometimes set up keys specially for that so I don’t have to press ctl-a-shell#)

Finally, a little addition to the .bashrc so that once the connection resumes everything returns, almost, to exactly where you had left off. This way you don’t even see the 6 hiccups that happened while sipping coffee. from http://taint.org/wk/RemoteLoginAutoScreen

# Auto-screen invocation. see: http://taint.org/wk/RemoteLoginAutoScreen
# if we're coming from a remote SSH connection, in an interactive session
# then automatically put us into a screen(1) session.   Only try once
# -- if $STARTED_SCREEN is set, don't try it again, to avoid looping
# if screen fails for some reason.
if [ "$PS1" != "" -a "${STARTED_SCREEN:-x}" = x -a "${SSH_TTY:-x}" != x ]
  [ -d $HOME/lib/screen-logs ] || mkdir -p $HOME/lib/screen-logs
  sleep 1
  screen -RR && exit 0
  # normally, execution of this rc script ends here...
  echo "Screen failed! continuing with normal bash startup"
# [end of auto-screen snippet]

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: