How to have multiple windows in a SSH terminal session?

6

2

From Mac OSX I login to a remote server that handles parallel computing jobs. I am not able to install anything on this server as it is administered by the university. I have multiple jobs running and want to monitor the log file in the following way:

tail -f logfile.log

Right now I have four jobs running, I open four terminal windows, SSH four times into the server, and do the tail command four times for the different logfiles (which are in different folders on the server). I have the feeling that I'm doing this in a sub-optimal way and am looking to just SSH once, then from one terminal window open all the four log files in separate windows (or tabs) with the tail command.

Is this possible? Or is it mandatory to sign in four times?

Saaru Lindestøkke

Posted 2013-07-16T18:27:06.367

Reputation: 1 275

I updated my answer under the assumption that you might want to actually have multiple osx windows instead of a terminal multiplexer. Is that a correct assumption? – dtmland – 2013-07-16T20:33:33.170

Your original answer did what I wanted. The only problem now is that I can't split vertically as the screen command is not patched (and I can't patch without the proper rights), but that's a minor nuisance. – Saaru Lindestøkke – 2013-07-16T20:35:56.920

It's worth noting that both screen and tmux allow you to run a command automatically on each new window. So if you use SSH login with a public key, you can open an arbitrary number of SSH sessions, to one or more servers, with just one command, and already split as you wish (I did this often with tmux, never tried with screen). – Paulo Almeida – 2013-07-16T20:44:55.473

Answers

12

The screen utility will allow to have multiple windows in a session. (You will have to install it on the server end)

This guy shows you the commands for how to split your views within the same terminal window.

It's also useful for re-connecting to a dropped session.

UPDATE:

Note that screen and tmux sessions will all "live" within one session which will still only give you one window or tab on OSX terminal app itself (even though these utilities allow you to have multiple "windows/views" within that view). See comments from this user:

ssh connections are a single process running in one shell, and when you create a new tab you are creating a new local shell that will not be running this process. Furthermore the remote server will not accept a duplicate connection from you without authentication. In essence, this is impossible to do. The closest thing you can do is make use of the bash history, and press the up arrow to scroll through your most recent commands until you get to the ssh command you used for your current connection, and then execute it.

If you still desire to have multiple windows/tabs in the OSX terminal app itself you will need to "login" multiple times. Several users have created scripts to try to aid this process.

This users solution might work best for you. This user creates a menu for his remote connections.

Other solutions I've seen only work with local sessions, but the idea is similar.

dtmland

Posted 2013-07-16T18:27:06.367

Reputation: 2 281

4

tmux is a newer option similar to screen. It may be easier to find for newer operating systems than screen. You can find the documentation here

Mobius

Posted 2013-07-16T18:27:06.367

Reputation: 238

1

My personal favorite tool for this is Byobu. It sits on top of tmux or screen, and has nice addons built into it on those programs to make easier to see how many terminals you have open. Really, it just makes those programs easier to use.

supercheetah

Posted 2013-07-16T18:27:06.367

Reputation: 836

-2

MrCricket

Posted 2013-07-16T18:27:06.367

Reputation: 1

1Is this your own project or are you related to it? Full disclosure in answers is a good habit. Downvote because: From Mac OSX I login to a remote server... – Saaru Lindestøkke – 2014-02-06T12:02:51.187

OSX - sorry, I didn't notice it. – MrCricket – 2014-02-06T13:24:18.987