How to ssh three remote linux box at the same time?
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How to ssh three remote linux box at the same time?
I have 4 linux machines, lets name it A, B, C, D. And the D machine can ssh to A, B, C using username TOM without password.
In machine A, B, C, They each contains a file ~/monitordata.
The thing I have to do is: in machine D monitor the three ~/monitordata files at the same time in the same screen.
And I don't have root previlege of none of the four machines.
Is it possible to do such job? Hope I express myself clear. And thanks in advance!
You might consider screen or tmux, split the window into three panes and ssh to A, B and C from them. The advantage is there is probably nothing to install as screen should be on just about any GNU/Linux box.
I have 4 linux machines, lets name it A, B, C, D. And the D machine can ssh to A, B, C using username TOM without password.
In machine A, B, C, They each contains a file ~/monitordata.
The thing I have to do is: in machine D monitor the three ~/monitordata files at the same time in the same screen.
And I don't have root previlege of none of the four machines.
Is it possible to do such job? Hope I express myself clear. And thanks in advance!
As others have mentioned, screen is an excellent tool for this.
To automate the process, I'd set up a .screenrc file with the following (change my generic user@host to your user/host info) and you call it with
> screen -c .screenrc
Code:
# Screen config file
# Turn off startup banner
startup_message off
# Status bar
hardstatus alwayslastline "%{.bW}%-w%{.rW}%n %t%{-}%+w %=%{..G} %H [system: %l] %{..Y} %m/%d %C%a "
# Virtual terminal & Split screen setup.
# Start virtual term one (In top region)
screen -t "Host1" ssh user@host1
# Split the session horizontally
split
# Move focus down to center region
focus down
# Start second virtual term (In center region)
screen -t "Host2" ssh user@host2
# Split the session horizontally -again-
split
# Move focus to bottom region
focus down
# Start third virtual term (In bottom region)
screen -t "Host3" ssh user@host3
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.