Making oneself at home
Ideas, curiosities, tricks,... the life.
Wednesday, November 19, 2008
Sunday, November 16, 2008
Hi all!!
I've come back!!! I'm here!!
And just to start with, some stuff about SSH with which I had troubles. May be it can be useful to others :-D
This is useful when you have several proxies and servers where you need to log in, in order to establish a connection to your home pc and you are at work, or viceversa. There is no pain in doing ssh connections from one to another, but what do we do when we need to transmit some files? Do we recursively copy the files from one server to another? NO!!! Here's my explanation (here you can see a Catalan version of this text).
All what you need are SSH tunnels.
I'm considering an example with 2 intermediate servers (namely SERVER1 and SERVER2), having YOUr computer and another TARGET one. Connecting from YOU to TARGET requires to connect firstly to SERVER1 and then SERVER2. How we transfer files from YOU to TARGET?
Now I know how to do it and it is quite easy:
- Define a tunnel to SERVER1 like this:
LocalForward 30022 SERVER2:22
This way, when you are connecting to "ssh -p 30022 USER2@localhost", actually you are connecting to SERVER2. - Whenever we consider SERVER2 to be TARGET, the process will finish here. But we need go through SERVER2 to get to TARGET. Define now:
LocalForward 30044 DESTI:22
This provides you a way ("ssh -p 30044 USERD@localhost") to connect to the TARGET computer from your local YOU computer. Isn't it fantastic!?
-------------------------------------------------------------------
Host SER1
User USER1
HostName SERVER1
Port 22
ForwardAgent yes
LocalForward 30022 SERVER2:22
Host SER2
User USER2
HostName localhost
Port 30022
ForwardAgent yes
LocalForward 30044 TARGET:22
Host DEST
User USERT
HostName localhost
Port 30044
-------------------------------------------------------------------
Save this file, usually with other stuff you have already there, and do the following operations:
- ssh SERV1
- ssh SERV2
These two operations are required to be done only once. Hereafter, we only need to perform as many connections like this as we need: - ssh DEST
This provides an SSH shell into TARGET. Additional commands you will be able to use with this: ssh, scp, rsync, etc.
I hope this will be useful for someone :-D
See you!!
Labels: config, configuration, proxy, ssh, ssh-tunnels, tunnels
