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 !
You can do it like this
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).