Open another terminal window with the same SSH session as original window
Solution 1
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.
Solution 2
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/
Solution 3
most probably you might use OpenSSH control master multiplexing described with examples here : https://en.wikibooks.org/wiki/OpenSSH/Cookbook/Multiplexing
Related videos on Youtube
![Tulains Córdova](https://i.stack.imgur.com/RQ8O6.png?s=256&g=1)
Tulains Córdova
Updated on September 18, 2022Comments
-
Tulains Córdova almost 2 years
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.
-
Tulains Córdova almost 11 yearsMaybe I wasn't clear enough. I have a terminal window with a remote ssh session into another server. I want to open a new tab connected to the same remote ssh session. Look at the edit in the question.
-
abchk1234 almost 11 yearsok..got your question. will search for the answer as i dint know it yet.
-
Tulains Córdova over 9 yearsThe remote host is Debian and it doesn't have gnome-terminal. What is the name of the terminal app in Debian ?
-
Tulains Córdova over 9 yearsDoes "screen" need not be installed in the remote host ?
-
Apologician over 9 years@user1598390 On my installation
(Version 7 - wheezy)
the default terminal app is gnome-terminal. There are other terminal applications install. They arexterm
,lxterm
, anduxterm
. I believe the most common on most distros will bexterm
. You can get a list of the terminal applicatons with the commandlinecd /usr/bin;ls *term*
. -
abchk1234 over 9 yearsI suppose it does.
-
Tulains Córdova over 9 yearsI have to connect to many production servers: Solaris servers (new versions as well as legacy versions), Debian servers (several versions) and RedHat servers (several versions). Having to install new software in all of them is out of question.
-
Tulains Córdova over 9 yearsI tried it and it doesn't work for me.
-
Apologician over 9 yearsWhat is the error message you get when you execute
cd /usr/bin;ls *term*
? In other words, what is the cli you executed and what was the error message? -
Tulains Córdova over 9 yearsThe error is when executing
xterm&
-->[1] 26953 postgres@serverxxx:/usr/bin$ X11 connection rejected because of wrong authentication. xterm: Xt error: Can't open display: localhost:10.0
Even though I ranxhost +
in the local machine. And even when I didssh -X
-
Apologician over 9 years@user1598390 You are having other issues that are separate from running an X terminal. Most likely you would get the same error if you tried to run xeyes and any other X application. You may have inadvertently deviated from the original login ID that was used to start the initial session. You can respond here or go into a chat room I setup to have extended discussion on this matter. The resolution may be to make sure you're using the same logged in ID in every case regarding this session instance. (chat.stackexchange.com/rooms/19029/expoundonanswer)
-
Tulains Córdova over 9 yearsI, in fact, deviated from the original login ID because the postgres user is prohibited by the administratos to open a ssh session, one has to login with a personal ID, then
su
into postgres. It works if don't dosu - postgres
. Remains to be solved how to do the trick after yousu -
into another user. -
Apologician over 9 yearsThe Stack Exchange system is advising for this to be moved into chat. They don't want the comments area to be used as a chat utility. I'll try to answer your new question by saying you may have access to the DISPLAY session if go into the new terminal before changing the userID, then running su to execute what you're trying to do.
-
abchk1234 over 9 yearsAh, here is something a friend told me about how he manages multiple machine installs: bjoernvold.com/forum/viewtopic.php?f=11&t=3228
-
YayDK over 6 yearsAlthough this technically works, it only does so if the remote server has gnome-terminal installed. Additionally, it bogs down the network. Ideally, a better solution would entail saving the connection information and starting an additional session with the same information. I have not found a solution for this yet but hope to (how I ended up here)
-
Apologician over 6 yearsYour question appears to be different from the user's question. I would use different
ssh
sessions to have two different terminals. As far as gome-terminal install, I try to gear my answer close to the user's question and the users objective. He specified gnome-terminal as part of the question (the tag part). Also, gnome-terminal is shipped as part of the Ubuntu suite. Some of the other flavors such asLubuntu
andxubuntu
might not have it installed by default, but as easy,sudo apt install gnome-terminal
will fix that... which the OP may have done. -
ComputerScientist almost 6 yearsWhen I use screen, I cannot scroll up and down, whereas I can scroll up and down in the normal command line (the one I get right after doing
ssh user@machine
). -
abchk1234 over 5 yearsTo scroll in screen, one needs to go in to copy mode by pressing Ctrl + A followed by [ key. cyberciti.biz/faq/… I agree its not very convenient.
-
Clyt about 5 yearsIf you see that gnome-terminal is not installed in the server, try
xterm
. It should be there on all linux systems -
Marc Vanhoomissen over 4 yearsWelcome to AU. To be very useful, you should summarize the key points of the link you refer to. This way, even if the linked document disappears, your answer remains valid.
-
Calmarius about 4 yearsThis will forward the image of the terminal, it doesn't open another one locally so it wasted a huge amount of bandwidth.
-
alper almost 4 yearsI get following error:
libGL error: No matching fbConfigs or visuals found
-
JolonB almost 3 years
gnome-terminal
opens on the host desktop for me. I had to usexterm
instead -
Sekomer over 2 yearsThis is the only great answer in the internet. Thank you very very much.
-
Admin about 2 yearsThis is a really bad answer, just like @Calmarius points out. Downvoted since none of the X forwarding/bandwidth issue is mentioned or explained.