66

Is there a way to open a terminal window ( or tab ) with another instance of an open SSH session ?

EDIT: I have a terminal window with a remote ssh session into a server. I want to open a new tab connected to the same remote ssh session.

With File->New Tab I get another tab but I have to open another ssh session to the remote server.

5 Answers5

56

Perhaps this could help: screen

It is not installed by default on Ubuntu, but is provided in the repositories.

It is very useful: ssh to a remote host and type screen to enter a screen session.

Start whatever time consuming task you like, and then press Ctrl+A followed by Ctrl+C to create a new window in the screen session.

This will spawn a new shell where you can do what you want. Create even more windows using the same command.

To switch between two windows quickly, use Ctrl+A followed by Ctrl+A again. As you can see, Ctrl+A puts screen in command mode.

Ctrl+A Ctrl+D will detach from the screen session. You can then disconnect from the host and log in again later and use screen -dr to resume your session.

To go to a specific screen window, type Ctrl+A followed by a number.

Screen will exit when all active windows are closed (or the shells within have exited).

I got this from SSH and SFTP sessions.

Edit-

tmux is an alternative to screen. http://www.sitepoint.com/tmux-a-simple-start/

abchk1234
  • 1,869
24

Connect to your remote server with:

ssh -X [remote-host]      

Now run:

gnome-terminal &

A terminal will appear on your local computer. From this terminal, you can run as many tabs or terminal windows as desired. They will all use the same ssh connection and be connected to the remote machine.

mitchus
  • 207
L. D. James
  • 25,444
2

most probably you might use OpenSSH control master multiplexing described with examples here : https://en.wikibooks.org/wiki/OpenSSH/Cookbook/Multiplexing

0

I've done this before: Launch gnome-terminal on the server. ctrl+Z then bg from your original terminal window.

I normally use ssh -X -C, so you might have to do that, but I'm not sure. Also, it'll use your server's settings instead of the ones on your machine, which is sometimes inconvenient.

-4

Yeah, in the terminal (menu) click on File -> New Tab

to open new tab in terminal

or are you asking for something else?

abchk1234
  • 1,869