Monday, 19 August 2013


 Tunneling Another TCP Session Through SSH

Problem: You want to secure a client/server TCP connection such as pop,imap,nntp,irc,vnc etc. both the client and server must reside on computers that run ssh.

Solution: Tunnel(forward) the TCP connection through SSH. To secure port 119, the NNTP protocol for usenet news, which you read remotely from

# ssh -f -N -L12345:localhost:119

While this tunnel is open, read news via local port 12345,

# export NNTPSERVER=localhost
# tin -r -p 12345

Tunneling or port forwarding uses ssh to secure another tcp/ip connection, such as an NNTP or IMAP connection. you first create a tunnel, a secure connection between an ssh client and server. Then you make your tcp/ip applications communicate over the tunnel.

ssh -f -N -L12345:localhost:119

 It establishes a tunnel between localhost and The tunnel has three segments,

1. The news reader on your local machine sends data to local port 12345. This occurs entirely on your local machine, not over the network

2. The local SSH client reads port 12345, encrypts the data, and sends it through the tunnel to the remote ssh server on

3. The remote ssh server on decrypts the data and passes it to the news server running on port 119. This runs entirely on not over the network.
there for when your local news client connect to local port 12345,
# tin -r -p 12345

the connection operates through the tunnel to the remote news server on Data is sent back from the news server to the news client by the same process in reverse.

The general syntax is:

ssh -f -N -Llocal_port_number:localhost:remote_port_number remote_host

No comments:

Post a Comment