0

Because I can only get to server3 from server2 (Server2 running CentOS7), I'm trying to create a "template" command or a script that I can use to :

  1. ssh to server2
  2. switch to another user in server2
  3. ssh into server3
  4. run commands in server3
  5. get the output printed in the console

The template I'm looking for would have 2 parts, the first one to ssh into server2 and switch users to connect to server3, the second part would be the actual commands that I want to run on server3

I'm having trouble with this command:

ssh -t user1@server2 ‘sudo -u user2 ssh -t user3@server3 “command1; command2; command3”’

It connects to server 2 and switch users but I keep getting:

cannot set terminal process group (-1): Inappropriate ioctl for device
bash: no job control in this shell

And when I add the --pty or -P flag to overcome the above error I get -P invalid option

I've also tried suggestions with script -q /dev/null but I still wasn't able to run commands on server3

I'm open to other ideas to be able to run my commands on server3 as long as it uses server2 as a jump/hub/proxy server.

Giacomo1968
  • 58,727
Tlink
  • 179
  • 1
  • 2
  • 11

0 Answers0