From now on I will need to use the SSH by tunneling to connect from my Home machine (Client) to my Office machine (Server) through a SSH Gateway because my Office machine is not directly connected to the Internet anymore, it seems a little bit complicated but I will try to simplify the things.
First of all the scheme to guide those who still may not have understood:
To access/connect the server I want, I can do by 2 ways:
- Connect to the SSH Gateway and then, connect to the desired server, it is the simplest solution but become quite costly and annoying when you need the SSH or SCP often, especially the SCP because you must copy to a tmp directory of the SSH Gateway all the files you want and then copy to desired server.
- Open a port in the client machine that connects to the desired server directly by tunneling, may seem more complicated but worth it. I will show how to do it bellow.
How to open the tunnel:
ssh -p <SSH_port_in_SSH_gateway> -fN -L <Port_to_use_in_client_machine>:<Server_IP>:<SSH_port_in_Server> <user>@<SSH_Gateway_IP>
How to use the tunnel – SSH:
ssh -p <Port_to_openned_in_client_machine> <user>@localhost
How to use the tunnel – SCP:
That’s it folks
Thanks to my friend Marcelo Gomes, who gave me the tips: Marcelo’s Blog (Blog in portugueses).