1

Case scenario:

When I open my terminal, screen starts automatically. This is useful because I often need multiple screens locally within the same terminal.

However, if I connect via SSH to a server and want to start a screen session on that server, it will create a local screen session instead.

i.e I want a parent (local screen) /children (remote screens) relationship between (or equivalent) instead of multiple SSH connections via local screens

  • Can you clarify what you mean 'it will create a local screen sesssion instead'? When I run screen, then ssh and start a screen session on the remote system, it starts a session on the remote session as expected. – yoonix Apr 30 '14 at 21:00
  • @yoonix Googled around and found examples with attach/detach and worked my way back. Posted clear answer below. Thanks for your help – hbt Apr 30 '14 at 21:15
  • Yep, same idea as with ssh itself. If you ssh to a host, then ssh to another host and hit ~. it will detach you from the session closest to you. Each level you want to pass through you need to add an initial character. So for closing a nested ssh session you would ~~.. – yoonix Apr 30 '14 at 21:32
0

Here is how:

Notice the @local vs @remote

user@local:$> screen

<Ctrl-a> c and a new local window is created

user@local:$> ssh user@remote

user@remote:$> screen

<Ctrl-a> a c and a new remote window is created

user@remote:$>

<Ctrl-a> c and a new local window is created

Basically <Ctrl-a> a [your screen command] allows you to call the sub-screen

0

If you want to run screen within another screen, you need to change screen control character combination (by default it's Ctrl + a).

Typically the first (outer) screen would be controlled with "Ctrl+a" (default), ie press "Ctrl+a" then "?" or "c"

Start screen within the screen (inner) with alternative control character, ie:

screen -e^Xx

Then you'd press "Ctrl+x" then "?" or "c" to operate inner screen.

  • You don't need to change the control character. If you need send a command two levels deep you just press CTRL-A A, and then whatever you want to the far system. It is a pain though. – Zoredache Apr 30 '14 at 22:41
  • Depends on the pain, but you are right – Alec Istomin Apr 30 '14 at 23:52

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.