0

I want to connect my remote machine via ssh, and I must connect to a proxy and in that proxy machine to connect my remote machine(remote machine is in the LAN of proxy machine, and it dosen't have a private ip address).

The following are my commands to connect my remote machine.

me@local_machine: ssh proxy # passwordless
proxy@proxy_machine: ssh my_remote_machine # passwordless
me@remote_machine:

How should I write a script in my local machine to connect my remote machine so that I don't need to type ssh command so many times to connect the remote machine.

I have a write a script in my local machine to connect the proxy, here show my code.

connect.sh

ssh -p 22022 proxy@proxy

But the above script is just connect the proxy machine, and in proxy machine, I still need to type ssh command to connect the remote machine.

What should I do, thank you !

Ryan Babchishin
  • 6,160
  • 2
  • 16
  • 36
GoingMyWay
  • 545
  • 2
  • 6
  • 10

1 Answers1

1

You can do it like this

ssh -t user@proxy_machine "ssh user@remote_machine"

You need to use -t to allocate a pseudo-terminal or it will fail and complain about not having a terminal (varying message based on OS).

Ryan Babchishin
  • 6,160
  • 2
  • 16
  • 36