0

Every morning I have to open a lot of remote sessions at work on a linux distribution, label the session-Windows, type ssh user@server and cd to a directory on that server. I want to save time and do this the following way automatically:

Open lets say five different remote session terminal Windows within a single frame, have them automatically labeled "Windows, Windows, etc", have them connecting to a remote server via ssh and finally cd to a certain directory on these remote servers, everything with a single terminal command or gui click.

What ways are there achieve this?

5 Answers 5

0

You could try the ClusterSSH app:

http://sourceforge.net/projects/clusterssh/

0

A bash script with something like this should work as long as n-term and gnome-terminal have similar syntax. You can get the geometry value by manually placing a window where you want it and then running xwininfo.

Cheers.


/usr/bin/gnome-terminal --geometry 95x9+2+844 --window --title=SERVER1 -e "ssh -t [email protected] 'cd /usr/local/bin; bash'" --active --tab --title=SERVER2 -e "ssh -t [email protected] 'cd /usr/local/bin; bash'" &

0

You could just write a simple script:

#!/usr/bin/bash

xterm -T "Window 1" -e "ssh -t user@server1  'cd /usr/share; othercmd; bash -i' "&
xterm -T "Window 2" -e "ssh -t user@server2  'cd /usr/share; othercmd;  bash -i'"&
xterm -T "Window 3" -e "ssh -t user@server3  'cd /usr/share; othercmd;  bash -i'"&
xterm -T "Window 4" -e "ssh -t user@server4  'cd /usr/share; othercmd;  bash -i'"&

That will spawn for xterms (user another terminal program as desired) each logging into the specified servers (server1-4) and then running the specified commands (a cd and othercommand) and leaving the specified shell (bash) running. The title is set with the -T option (for xterm, other terminal emulators may .... have different options).

Not pretty, but not horrendous either.

You could also use screen rather than xterms and probably get this all done in a specific screen.rc file. The XFCE Terminal program (my current favorite, usable in any other DE beside XFCE) accepts the same command line options. Gnome-terminal does not. Not sure about KDE or others, but I'm sure there's something similar.

In XFCE Terminal, replace the script with one line like this:

#!/usr/bin/bash

Terminal --tab -T "Window 1" -e "ssh -t root@flock  'cd /usr/share; bash -i' " --tab -T "Window 2" -e "ssh -t root@treepie  'cd /usr/share; bash -i'" --tab -T "Window 3" -e "ssh -t root@magpie  'cd /usr/share; bash -i'" --tab -T "Window 4" -e "ssh -t root@raven  'cd /usr/share; bash -i'"&

... and you'll get one window with multiple tabs so labeled.

0

It's a matter of taste, but I would strongly recommend you look into tmux. It's a terminal multiplexer and your use case isn't exactly the primary one, but you could very easily automate the creation of a session with windows and panes named already and laid out to your taste and then simply connect to that (assuming the machine on which tmux runs will run perpetually). Alternatively you can write a script to create the session to your taste and start it up manually. You can also do that at boot time already and later connect to it. The possibilities are nearly endless.

And yes, tmux allows to send commands to the windows and panes. So you are able to achieve all of that without much hassle. You can basically define a command to start each pane with and then after that send strings (not really commands, you could also make tmux "type" something into Vim) to those.

Look at the screenshots on their website - or using an image search for that matter - and let that convince you.

0

secpanel has ClusterSSH integration, maintains your remote host bookmarks and titles the terminal windows.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .