SSH Tunnel

A secure shell (SSH) tunnel consists of an encrypted tunnel created through a SSH protocol connection. Users may set up SSH tunnels to transfer unencrypted traffic over a network through an encrypted channel.

autossh

Autossh is a program to start a copy of SSH and monitor it, restarting it as necessary should it die or stop passing traffic.

autossh -M 0 -L 8080:localhost:8080 example.com -g

Install:

Authentication with generated key pair:

Netbios SSH tunnel

Entities:

The SSH server on the file /etc/ssh/ssh_config must have GatewayPorts yes.

The SSH client must be able to reach the SSH server and the netbios server.

On the ssh client, issue the following commands:

Now the Netbios server can be reached through ports 139 and 445 in the SSH server.

MS SQL Server tunnel

On the ssh client, issue the following commands:

Change passphrase with ssh-keygen

   1 $ cd ~/.ssh/
   2 #To change DSA passphrase, enter:
   3 $ ssh-keygen -f id_dsa -p
   4 #To change RSA passphrase, enter:
   5 $ ssh-keygen -f id_rsa -p

Script crontab establish connection

Crontab entry

0 0 * * * /root/autossh.sh

File to connect with autossh, /root/autossh.sh

   1 killall autossh
   2 /usr/local/bin/autossh -i /root/.ssh/id_dsa -M 0 root@sshdServer -R 2222:192.168.1.1:22 -f -N
   3 /usr/local/bin/autossh -i /root/.ssh/id_dsa -M 0 root@sshdServer -R 139:192.168.1.2:139 -f -N

SSHTunnel (last edited 2013-12-25 19:10:41 by 31)