daemon issue 14 SSH Port Forwarding Yannis Tsopokis Wednesday, April 26 th 2006
SSH (SSH client) is a program that allows as to connect to a remote computer and execute commands. Its difference from telnet is that it establishes a secure (encrypted) communication channel. Furthermore we can send any kind of data through this channel. We will discuss how we can use ssh to establish a secure channel, not for executing remote commands, but to transfer data, even between nodes that cannot contact each other directly (due to firewalling or other reasons) What is ssh SSH port forwardingWednesday, April 26 th
Lets say we want to connect with an Oracle DB server that only accepts database connections from an ip range. How can we connect to the db server from another ip? With ssh -L ! ssh -L : : You specify that port xxx of the local host will be forwarded to port yyy of remote-host, through host-gateway. ***Only root can forward privileged ports (<=1024)*** What we want to do How to use it SSH port forwardingWednesday, April 26 th
ssh -L 1521:dbserver.domain.com:1521 -Nf which forwards local port 1521 (oracle default), through host.domain.com (which must have sshd running), at port 1521 of dbserver. We will be asked for our password of userx at host.domain.com! client host dbserver incoming port 1521 Example incoming port 1521 SSH port forwardingWednesday, April 26 th
ssh -L 1521:dbserver.domain.com:1521 -Nf in this case we have the same result but it is more secure since the data travel through the encrypted channel up to dbserver, while in the previous example data travelled unencrypted from host to dbserver. client dbserver incoming port 1521 Example incoming port 1521 SSH port forwardingWednesday, April 26 th
Another occasion is when we want to mount a remote file system, and we cannot talk to the remote host directly. we first open the encrypted channel ssh -L 6666: :139 -Nf and then mount the remote file system mount -t smbfs -o port=6666 //localhost/share/remote_folder Mount remote filesystem SSH port forwardingWednesday, April 26 th
localhost remote ssh -R : : There also is reverse port forwarding, which does the reverse. It forwards port xxx of remote-host to port yyy of local-host. Reverse port forwarding incoming port xxx incoming port yyy SSH port forwardingWednesday, April 26 th
The end! SSH port forwardingWednesday, April 26 th References: [1] Openssh : [2] SSH: The Secure Shell, O'Reilly Book by Danie J. Barret & Richard E. Silverman. [3] man page of ssh. [4] ProxyTunnel: [5] ssh tunnels: