2

Due to some security policy I had to ssh into a remote machine using another remote machine to which I ssh-ed. Here is the situation. I have access to BSD box at work and the access is only available on wired office network. Apart from this BSD box I have my own RHEL dev box which is wired network and I can access it even from home using VPN. So when am at home I remote ssh to my RHEL dev box and then ssh to my BSD box. There are times when my connection to this RHEL is dropped. What happens to my connection to BSD box when my connection to RHEL is dropped? How can I manage these connections?

3

You'll need to run something like GNU screen on the RHEL box if you want to be able to re-connect to the ssh session to your BSD box.

  1. ssh to RHEL
  2. run screen
  3. ssh (from within screen) to BSD

  4. if/when the ssh to RHEL dies, ssh back in and reconnect to the screen session with screen -d -RR or similar.

See the screen man page for details about the various re-attachment options. I use -d -RR.

BTW, you may want to edit your ~/.screenrc and redefine screen's Escape key...IMO the default of ^A is annoying because ^A means "move cursor to beginning of line" in emacs-like editing (which is the default on bash and some other shells). I redefine mine to ^K because it isn't used by many things so pressing ^Kk to send a ^K to the underlying app is no big deal while having to type ^Aa to send ^A to bash all the time is a major PITA.

e.g.

# Instead of Control-A, make the escape/command character be Control-K
escape ^Kk
  • I have been avoiding screen. I guess its hight time I start using it. Thanks! – Kumar Aug 31 '12 at 6:16
  • avoiding screen? once you start using it, you'll wonder why you put it off so long! – cas Aug 31 '12 at 6:42
  • 2016 calling! Avoid screen and go straight to Tmux, a beautifully designed terminal multiplexer that proves configuration files or or stanzas for status lines needn't look like a dog just rolled over your keyboard for a minute. You won't want to miss splitting your windows (tabs) vertically and horizontally however you please, or uncomplicated 256 terminal colors and full UTF-8 support. – 0xC0000022L Sep 16 '16 at 17:23
  • @0xC0000022L i finally got around to switching to tmux a few months ago, partly because your comment about UTF-8 support made me go looking for 'how to convert from screen to tmux' pages (i wanted to duplicate my existing screen environment in tmux as much as possible, not start from scratch). I don't care at all about status lines, don't care much about splitting windows, but UTF-8 is important. there's a few trivial things I prefer about screen (largely out of ingrained habit), but overall tmux is better. you have to nuke the ghastly default colour scheme first, though...easily done. – cas Dec 22 '16 at 15:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.