quinta-feira, agosto 04, 2016

How can I have multiple terminal sessions through one single SSH connection? - Ask Ubuntu

command line - How can I have multiple terminal sessions through one single SSH connection? - Ask Ubuntu


How can I have multiple terminal sessions through one single SSH connection?

Just like windows terminal for windows.
mstsc for linux like, this is an ssh that could run in background

GNU Screen is the answer you've been looking for - but it's a lot like Vi. You've got a lot of learning of commands to setup a successful Screen environment. Here's some stuff to get you started. First of all you'll want this .screenrc http://paste.ubuntu.com/473764/ save it on the remote server in your users home folder. Next install screen on the remote machine (sudo apt-get install screen) Next you'll want to fire it up here are some commands for "firing up screen":
screen - This is pretty simple. It starts a new screen session screen -ls - List all active screen sessions. Yes you can have multiple terminals inside multiple screens. SO SWEET.
screen -ls
There is a screen on:
    16467.pts-0.ubuntu  (08/05/2010 07:47:53 PM)    (Detached)
1 Socket in /var/run/screen/S-marco.
screen -x <pid> - This will resume a Detached screen session, IE: screen -x 16467
Once you're in a Screen (and you've employed my sample .screenrc file) You'll see the following along the bottom:
(LOAD) 0$* bash
Which is the servers load and a list of all open "terminal tabs". Currently only one window. Type something then Press this Key Combination: Ctrl + A release, then press cCtrl + A is the escape sequence. All commands are started with this combination. c is create new tab. You'll notice the footer has (LOAD) 0-$ bash 1$* bash which shows that there is another tab open and the active tab is number 1. You can open a maximum of 60 tabs per screen session.
If you want to exit screen but keep it running use Ctrl + A then d which will detach your session. Finally you can close tabs by using Ctrl + A then k which will kill that tab (if it locks up) but typically you can just type exit as if you were in a terminal and it will close that tab.
Lastly to list all windows open you can type Ctrl + A then ".
There are a whole slew of options available for Screen you should pour over the man file for more. There are some drawbacks. You can't use your scroll bar in Screen you have to use buffer controls to roll back, however the above is enough to get you started to see if this is a viable option. A great thing about this and something I've dealt with a lot as a System Administrator - network connectivity. If your network drops out your operations won't be lost! Since screen is running on the server. You simply need to log back in via SSH then screen -ls and screen -x back into your session.

Nenhum comentário: