![]() ![]() If you are seriously into tunnels, and running an MS-Windows client, then I suggest looking at Putty Tunnel Manager which uses Putty to set up and run tunnels easily without needing to have an open putty console. Now you can use the saved connection to log in to your server and after you successfully log in, every time you connect to port 4000 on your computer you will actually connect to port 3306 on the server. Then navigate back to "session" and click "Save" to keep your settings for the next time. Then in the tree on the left side, navigate to Connection->SSH->Tunnels and create a new "local" tunnel with the source port 4000 and the destination "localhost:3306" (because the destination address is resolved on the server, from the server's point of view the MySQL port is on the localhost). To set it up, open the Putty configuration dialog, select the setting of the connection you normally use to access your server and click "load" (and not "open"). The target of the tunnel need not be the same server - it can be any other valid address, which - in the case it's not the server running the SSH server itself - will see the incoming connection as if it came from the SSH server instead of from your client. The way it works is that you create an SSH connection to the server (which is secure) and then instruct the SSH to listen to a port on your side and forward whatever connections come in - to a specific port on a specific host address on the server side. The simple answer is yes, but please note that the tunnel is actually started on your computer. Now you can use the saved connection to log in to your server and after you successfully log in, every time you connect to port 4000 on your host you will actually connect to port 3306 on the Ubuntu server. Then navigate back to session and click Save to keep your settings for the next time. In the tree on the left side, navigate toĪnd create a new local tunnel with the source port 4000 (123 in the image) and the destination localhost:3306 (localhost:456 in the image). ![]() Start Putty and enter your usual connection settings (Hostname or IP address) Connections to the green port (in your case port number 4000) are forwarded to the pink MySQL port 3306 of the localhost of your Ubuntu server machine (i.e. The blue box called your host is your Windows machine from which you start Putty to your Ubuntu server, called remotehost in my image. The first image represents your situation. Ssh -R sourcePort:forwardToHost:onPort connectToHost means: connect with ssh to connectToHost, and forward all connection attempts to the remote sourcePort to port onPort on the machine called forwardToHost, which can be reached from your local machine. Remote: -R Specifies that the given port on the remote (server) host is to be forwarded to the given host and port on the local side. Ssh -L sourcePort:forwardToHost:onPort connectToHost means: connect with ssh to connectToHost, and forward all connection attempts to the local sourcePort to port onPort on the machine called forwardToHost, which can be reached from the connectToHost machine. If you have a MySQL installation on your local machine, it runs on port 3306 by default therefore, don’t use 3306 for the local. username remote host local port The local port your database tool connects to. Local: -L Specifies that the given port on the local (client) host is to be forwarded to the given host and port on the remote side. The syntax for creating the SSH tunnel is ssh -L local port: database host: remote port \. You also have a script at for creating an OpenSSH tunnel over a TAP interface.The machine, where the ssh tunnel command is typed (or in your case: Putty with tunneling is started) is called »your host«. If you want to access/tunnel a network instead of a single machine, you also have to activate ip forwarding, as in: sudo sysctl -w _forward=1 ![]() NET_LOCAL=192.168.8.0/24 # Network on this side of the tunnel NET_REMOTE=192.168.0.0/16 # Network on the other side of the tunnel Now, on the client it’s as easy as to run ssh with some parameters, my script for launching it is: #!/bin/sh Using OpenSSH in Linux, tunnels can be created over SSH using either TUN or TAP interfaces, as long as proper routing is setup and ip forwarding where appropriate.įor creating a TUN tunnel, will leave here a practical script, from Ip Tunnel Over Ssh With Tun the script assumes you are running as root.Īdd “PermitTunnel yes” to /etc/ssh/sshd_config ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |