SSH Tunneling on Linux and Mac OS X

Agradecimiento a :

You can use OpenSSH to open a tunnel through nexus (our SSH gateway system) to your host on the Genome Sciences network. Once you’ve opened the tunnel, connecting to the specified local port will be just like connecting directly to the GS host.

[me@mylocal ~]$ ssh -L

The option «-L» indicates to open a tunnel on your local system. The «-L» option takes an argument of the format local_port:remote_host:remote_port. In the above example we’re opening a tunnel on port 2222 of our local system. The tunnel goes to port 22 (SSH port) of the host Once the tunnel is established, you’ll have to open another terminal on your local system and run the command below.

[me@mylocal ~]$ ssh -X -p 2222 localhost

You’ll now be connected to The «-X» option forwards graphics from Linux programs that run on your remote GS host to your local computer. If you’re using Mac OS X you’ll need to be sure to have the X11 program open. If you’re just running text based programs, you can omit the «-X» option. You can also use this tunnel for transferring files with scp or sftp.

[me@mylocal ~]$ scp -P 2222 localhost:/net/mylab/vol1/home/me/data.txt /home/me

[me@mylocal ~]$ sftp -oPort=2222 localhost

The above scp command will copy data.txt on the remote computer to /home/me on your local computer. You can use an SSH tunnel to connect to most internal services. Below is an example for connecting to the web server, mywebserver.

[me@mylocal ~]$ ssh -L

You would then open a web browser on your local system and enter the address http://localhost:8080 and you’ll be connected to your internal web server.

Deja un comentario