Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 3 down vote accepted

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.


# Instead of Control-A, make the escape/command character be Control-K
escape ^Kk
share|improve this answer
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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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