Çarşamba , 2 Aralık 2020
Comprehensive Guide on SSH Tunneling 1 – 01

Comprehensive Guide on SSH Tunneling

Basically, tunneling is a process which allows data sharing or communication between two different networks privately. Tunneling is normally performed through encapsulating the private network data and protocol information inside the public network broadcast units so that the private network protocol information visible to the public network as data. 

SSH Tunnel:  Tunneling is the concept to encapsulate the network protocol to another protocol here we put into SSH, so all network communication is encrypted. Because tunneling involves repackaging the traffic data into a different form, perhaps with encryption as standard, a third use is to hide the nature of the traffic that is run through the tunnels.

Types of SSH Tunneling:     

  1. Dynamic SSH tunneling
  2. Local SSH tunneling
  3. Remote SSH tunneling

Objective:  To establish an SSH connection between remote PC and the local system of the different network.

Here I have set my own lab which consists of three systems in the following network:

SSH server (two Ethernet interface) 

IP 192.168.1.104 connected with the remote system

IP 192.168.10.1 connected to local network system 192.168.10.2

SSH client (local network) holds IP 192.168.10.2

Remote system (outside the network)

In the following image, we are trying to explain the SSH tunneling process where a remote PC is trying to connect to 192.168.10.2 which is on INTRANET of another network. To establish a connection with an SSH client (raj), remote PC will create an SSH tunnel which will connect with the local system via SSH server (Ignite).

NOTE: Service SSH must be activated

Comprehensive Guide on SSH Tunneling 2 – 0

Given below image is describing the network configuration for SSH server where it is showing two IP 192.168.1.104 and another 192.168.10.1

Comprehensive Guide on SSH Tunneling 3 – 1

Another image given below is describing network configuration for SSH client which is showing IP 192.168.10.2

Comprehensive Guide on SSH Tunneling 4 – 2

Dynamic SSH Tunneling through Windows

Remote Pc is trying to connect to SSH server (192.168.1.104) via port 22 and get successful login inside the server. Here we had used putty for establishing a connection between SSH server (Ubuntu) and remote user (Windows).

Comprehensive Guide on SSH Tunneling 5 – 3

Similarly now Remote PC trying to connect with Client PC (192.168.10.2) via port 22, since they belong to the different network, therefore, he receives network error.

Comprehensive Guide on SSH Tunneling 6 – 4

Step for Dynamic SSH tunneling

  • Choose option SSH >Tunnel given in the left column of the category.
  • Give new port forwarded as 7000 and connection type as dynamic and click on ADD at last.
Comprehensive Guide on SSH Tunneling 7 – 5

Now connect to SSH server 192.168.1.104 via port 22 and then click on open when all things get set.

Comprehensive Guide on SSH Tunneling 8 – 6

First, it will connect to the SSH server as you can see we are connected with SSH server (Ignite).

Comprehensive Guide on SSH Tunneling 9 – 7

Now login into putty again and give IP of client system as Host Name 192.168.10.2 and Port 22 for SSH then click on open.

Comprehensive Guide on SSH Tunneling 10 – 8

The open previous running window of putty choose Proxy option from the category and follow given below step:

  • Select proxy type as SOCKS 5
  • Give proxy hostname as 127.0.0.1 and port 7000
  • Click on open to establish a connection.
Comprehensive Guide on SSH Tunneling 11 – 9

Awesome!! We have successfully access SSH client (raj) via port 7000

Comprehensive Guide on SSH Tunneling 12 – 10

Dynamic SSH Tunneling through Kali Linux on Port 80

Now we are employing Kali Linux for SSH tunneling and demonstrating how an attacker or Linux user can take the privilege of Tunneling and can establish an SSH connection with client systems.

1 ssh -D 7000 ignite@192.168.1.104

Enter the user’s password for login and get access to the SSH server as shown below.

Comprehensive Guide on SSH Tunneling 13 – 11

Next, we need to set a network proxy for enabling socksv5 and for that follow below steps.

  • In your web browser “Firefox” go to option for general setting tab and open Network Proxy.
  • Choose No Proxy
  • Enable socksv5

Add localhost, 127.0.0.1 as Manual proxy

Comprehensive Guide on SSH Tunneling 14 – 12

So from given below image, you can perceive that now we able to connect with the client: 192.168.10.2 via port 80.

Comprehensive Guide on SSH Tunneling 15 – 13

Dynamic SSH Tunneling through Kali Linux on Port 22

Now connect to client machine through given below command:

1ssh -D 7000 ignite@192.168.1.104
Comprehensive Guide on SSH Tunneling 16 – 14

Install tsocks through apt repository using the command:

1apt install tsocks

tsocks – Library for intercepting outgoing network connections and redirecting them through a SOCKS server. 

Comprehensive Guide on SSH Tunneling 17 – 15

Open the tsocks.conf file for editing socks server IP and port, in our case we need to mention below two lines and then save it.

Server = 127.0.0.1

Server_port = 7000

Comprehensive Guide on SSH Tunneling 18 – 16

Now connect to SSH client with the help tsocks using given below command.

1tsocks ssh raj@192.168.10.2

Enter the password and enjoy the access of SSH client.

Comprehensive Guide on SSH Tunneling 19 – 17

Local SSH Tunneling through Windows

Local tunneling is a process to access a specific SSH client machine for communication. It let you establish the connection on a specific machine which is not connected from the internet.

The only difference between dynamic tunneling and local tunneling is that dynamic tunneling requires socks proxy for tunneling all TCP traffic and local tunneling only required destination IP address.

Step for SSH Local tunneling

  • Use putty to connect SSH server (192.168.1.104) via port 22 and choose option SSH >Tunnel given in the left column of the category.
Comprehensive Guide on SSH Tunneling 20 – 18
  • Give new port forwarded as 7000 and connection type as local 
  • Destination address as 198.168.10.2:22 for establishing a connection with the specific client and click on ADD at last.
  • Click on open when all things get set.
Comprehensive Guide on SSH Tunneling 21 – 19

First, this will establish a connection between the remote pc and SSH server.

Comprehensive Guide on SSH Tunneling 22 – 20

Open a new window of putty and follow given below step:

  • Give hostname as localhost and port 7000 and connection type SSH.
  • Click on open to establish a connection.
Comprehensive Guide on SSH Tunneling 23 – 21

Awesome!! We have successfully access SSH client via port 7000 

Comprehensive Guide on SSH Tunneling 24 – 22

Local SSH Tunneling through Kali Linux

Now again we switch into Kali Linux for local tunneling which is quite easy as compared to dynamic. Execute given below command for forwarding port to the local machine.

1ssh -L 7000:192.168.10.2:22 ignite@192.168.1.104
Comprehensive Guide on SSH Tunneling 25 – 23

Now open a new terminal and type below command for connecting to SSH client.

1ssh raj@127.0.0.1 -p 7000

Awesome!! We have successfully access SSH client via port 7000 

Comprehensive Guide on SSH Tunneling 26 – 24

Remote SSH Tunneling through Putty

Remote tunneling is functional when a client machine wants to access a remote system which is outward from its network.

First, need to install putty in our SSH server (ignite) and then follow given steps.

Step for remote tunneling

  • Enter remote system IP 192.168.1.108
  • Mention port 22
  • Go to SSH>tunnel options
Comprehensive Guide on SSH Tunneling 27 – 25
  • Give new port forwarded as 7000 and connection type as Remote
  • Destination address as 198.168.10.2:22for establishing a connection with the specific client and click on ADD at last.
  • Click on open when all things get set.
Comprehensive Guide on SSH Tunneling 28 – 26

Now the server will get connected to Remote system as shown in below image.

Comprehensive Guide on SSH Tunneling 29 – 27

Come back to the remote system and enter the following command to with SSH client machine.

1ssh raj@127.0.0.1 -p 7000

From given below image you can observe that we had successfully connected with SSH client machine via port 7000.

Comprehensive Guide on SSH Tunneling 30 – 28

Remote SSH Tunneling through Ubuntu

If you are not willing to use putty for remote tunneling then you can execute the following command

1ssh -R 7000:192.168.10.2:22 root@192.168.1.108

Here 192.168.1.10.2 is our local client (raj) IP and 192.168.1.108 is our remote system IP.

Comprehensive Guide on SSH Tunneling 31 – 29

Come back to the remote system and enter the following command to with SSH client machine.

1ssh raj@127.0.0.1 -p 7000

From given below image you can observe that we had successfully connected with SSH client machine via port 7000.

Comprehensive Guide on SSH Tunneling 32 – 30

18 Yorumlar

  1. Very nice article, exactly what I was looking for.

  2. I am regular reader, how are you everybody? This article
    posted at this web site is really pleasant.

  3. Pretty! This was an incredibly wonderful article. Many
    thanks for supplying this info.

  4. Great post. I was checking constantly this weblog and I’m
    inspired! Extremely helpful information particularly the closing phase 🙂 I care for
    such info a lot. I was looking for this certain info for a very long time.
    Thanks and good luck.

  5. Wonderful blog! I found it while surfing around on Yahoo
    News. Do you have any suggestions on how to seo to get listed in Yahoo News?
    I’ve been trying for a while but I never seem to get there!
    Thanks

  6. Generally I do not earn post on blogs, buut I woupd like to say that this write-up very forced me to
    check out and do so! Your writing style has been surprised
    me. Thanks, very great post.

  7. Wow, incredible blog layout! How long have you been blogging for?

    you made blogging look easy. The overall look of your web site is excellent,
    let alone the content!

  8. Hi, I do think this is an excellent website. I stumbledupon it ;
    ) I am going to revisit yet again since I saved as a favorite it.
    Money and freedom is the best way to change, may you be rich and
    continue to guide others.

  9. magnificent put up, very informative. I wonder why the other specialists of this sdctor do not notice this.
    You should continue your writing. I’m sure, yoou have a geat readers’ base already!

  10. Tһis is very interesting, You’re a very skіlled blogger.
    I’ve joined your feed and look forward to
    ѕeeқing more of your great post. Also, I’ve sbared your site in my social networks!

  11. Ηi! I’m аt ᴡork surfing aroսnd yoᥙr blog fгom my new
    apple iphone! Ꭻust wаnted to sayy I love reading tһrough you blog ɑnd ⅼօok forward
    tо all your posts! Keеp uρ the excellent work!

  12. This iѕ very interesting, You are a very skilled bloggeг.
    I have ϳoined your feed and looқ forward tⲟ seekіng mkre of уour excellent
    post. Ꭺlso, I have shared your site in my
    ѕocial networks!

  13. I all the time used to study piece of writing in news
    papers but now as I am a user of internet so from now I am using net for articles, thanks to web.

  14. Ꮃay cool! Some extгemely valid points! I аpprechiate you
    penning tһis аrticle and also the rest of tһe ѕite is extremely good.

  15. I’m amazed, I have to admit. Rarely do I
    encounter a blog that’s both educative and engaging, and without
    a doubt, you’ve hit the nail on the head. The issue is something
    not enough folks are speaking intelligently about.
    I’m very happy I stumbled across this in my hunt for something concerning this.

  16. Hi there, just wanted to say, I loved this article.
    It was funny. Keep on posting!

  17. Attractive portion ᧐f content. I just stumbled upon yоur weblog and in accession capital tо say that Ӏ acquire actuɑlly enjoyed
    account ʏour weblog posts. Ꭺnyway I wilⅼ be subscribing
    to үouг augment аnd even I fulfillment ʏou get admission to ⅽonstantly
    rapidly.

  18. When I originally commented І appear tto have clicked on thе -Notify me when new comments are аdded- checkbox ɑnd now eveгy time a
    comment is dded Ӏ recieve 4 emails with tһe exact same
    comment. Is there а means үoս can remopve me frοm tһat service?
    Kudos!

    Ηere іѕ my blog gift card codes