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?
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.
- ssh to RHEL
ssh (from within screen) to BSD
if/when the ssh to RHEL dies, ssh back in and reconnect to the screen session with
screen -d -RRor similar.
See the screen man page for details about the various re-attachment options. I use
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