You are not logged in.

#1 2016-09-11 21:34:26

Horizon_Brave
Operating System: Linux-Nettrix
Registered: 2015-10-18
Posts: 1,473

Getting SSH Output From Remote to Local Session?

Hi everyone, after about 2 days of scratching my head on this one, I'm finally ready to punt this and ask for some actual help. Here's the situation. We have 1 server, that runs multiple VM's. To gain access to those VM's we ssh from host01  to the other vm hosts. For example when we first log into the machine, we're always on host01. Then from there we can ssh to host02, host03 etc...  What I'd like to do is log into host01 as per normal, and have a script that ssh's to host03, runs a few commands on host03, but puts the output of those commands onto the tty of the screen of host01. The script I have looks like this:

#! /bin/bash

ssh -t -t $tar_host & <<EOF

sleep 2
echo "On host03"
EOF

echo "worked?"
exit 0

What this does is basically logs me onto host03, successfully, but there's no output from the echo "On host03" obviously. 

What I would want is to be able to ssh onto host03, run a list of commands in the EOF here document list, but have all of the output from those commands make it's way back to my host01 tty..

Is something like this possible? Would I need to open up a separate tty session?  I've seen a lot of recommendations about playing around with /dev/tty  and /dev/pts/  etc.. but nothing concrete so far..

Thank guys, any help is appreciated!


"I have not failed, I have found 10,000 ways that will not work" -Edison

Offline

#2 2016-09-12 06:27:25

ohnonot
...again
Registered: 2015-09-29
Posts: 5,592

Re: Getting SSH Output From Remote to Local Session?

i don't understand.
are you first ssh-ing into the baremetal host, and from there into a vm, inception-style?
why don't you log on to host03 straight away?
and please be precise about your usage of "host" and "guest", i have the feeling you were using "host" where you meant "guest".
or maybe i just don't understand.

Offline

#3 2016-09-12 14:51:22

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 2,746

Re: Getting SSH Output From Remote to Local Session?

how about
ssh user1@server1 'some && command'

Offline

Board footer

Powered by FluxBB