caaruiz
caaruiz

Reputation: 99

SSH: Run command through sub server

My goal is to be able to send a command to an old server that can only be reached by going through the new server.

I want to be able to automate this as much as possible. I want to be able to just run a script and it will do the work for me so that I don't have to type.

Meaning I would have to do the following:

ssh user@newserver

and then

ssh user@oldserver

Once I reach the old server I need to be able to run

curl icanhazip.com

and

cat /var/spool/cron/user

So far I was only able to do the following:

ssh -t -t root@newserver "ssh root@oldserver"

That would only allow me to reach the server, but I would have to manually send other commands.

I would Ideally want to be able to run something like this:

ssh -t -t root@newserver 'ssh root@oldserver "cat /var/spool/cron/user"'

Upvotes: 1

Views: 123

Answers (1)

caaruiz
caaruiz

Reputation: 99

ssh -t -t root@newserver 'ssh root@oldserver "cat /var/spool/cron/user"'

This Actually worked. Not sure why it didn't before.

Upvotes: 2

Related Questions