SSH Forwarding

From Nuclear Physics Group Documentation Pages
Jump to navigationJump to search

To access web interfaces on other systems, use SSH port forwarding, like so:

ssh -L [localport]:foreign-system:[foreignport] tunnel-system

This makes a connection yourmachine:localport <-> <tunnel-system> <-> foreign-system:foreignport

So, from your local system to open a mysql connection to "roentgen", use:

 ssh -L 33306:roentgen:3306 gourd.unh.edu

You can now use mysql as if it is running locally on port 33306:

 mysql -P 33306 -h 127.0.0.1 -p

Note: yes, you must use -h 127.0.0.1, or else mysql will try /tmp/mysql.sock and fail to connect, since it is trying your locally running mysqld.

Note: In order to forward privileged ports, you need root access. SO DON'T!