{"id":85,"date":"2020-05-08T13:43:17","date_gmt":"2020-05-08T12:43:17","guid":{"rendered":"http:\/\/www.labtinker.net\/?p=85"},"modified":"2020-05-08T13:43:17","modified_gmt":"2020-05-08T12:43:17","slug":"ssh-forwarding-with-putty","status":"publish","type":"post","link":"http:\/\/18.135.13.153\/?p=85","title":{"rendered":"SSH Forwarding (Part 2)"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Again nothing earth-shattering here, a simple exercise building on the previous post.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>What do we want to do?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This time we want to build a tunnel from a Windows host to a Linux one using the ssh utility Putty and then connect back to the Windows host down the tunnel using a remote desktop program.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>The Lab Setup<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You\u2019ll notice the employment of the same diagram to save effort but with different ip addressing to catch those sleeping at the back; this time the Linux host has the ip address 10.20.10.60 and the Windows host has the ip adddress 10.20.10.30<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"482\" height=\"199\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/05\/Windows-Linux2.png\" alt=\"\" class=\"wp-image-86\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/05\/Windows-Linux2.png 482w, http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/05\/Windows-Linux2-300x124.png 300w\" sizes=\"auto, (max-width: 482px) 100vw, 482px\" \/><figcaption>Figure 1<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Scenario Overview<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We\u2019ll connect out from Windows using ssh on the standard&nbsp; port 22 &nbsp;as that\u2019s what our Linux host is listening on. I didn\u2019t set the Linux host to listen with an ssh sever on port 80 as I did last time mainly because I forgot to but it could easily be done. BTW, I should say all ports mentioned are tcp unless otherwise stated.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Unlike Linux, Windows doesn\u2019t come with a pre-installed ssh utility but there is a superb free one called Putty. (https:\/\/putty.org\/) which can be downloaded and installed or just run as an executable. This is written by one man, Simon Tatham, and is probably used millions of times by millions of people every day. Kudos to Mr Tatham for his generosity in releasing this quality of software without cost.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Having doffed our cap to Mr T, we move on. &nbsp;Putty has many features and &nbsp;connecting to our Linux host is the most basic of them; we pop in the ip address in and click the ssh radio button as demonstrated in Figure 2:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"325\" height=\"170\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/05\/Putty-Window.png\" alt=\"\" class=\"wp-image-87\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/05\/Putty-Window.png 325w, http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/05\/Putty-Window-300x157.png 300w\" sizes=\"auto, (max-width: 325px) 100vw, 325px\" \/><figcaption>Figure 2 Main Putty window.<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Ah, ah, but not so fast. We have to delve elsewhere before we connect. To create a tunnel which the Linux host can connect we head to the \u2018Tunnels\u2019 menu\u2026<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"109\" height=\"276\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/05\/Putty-Tunnels.png\" alt=\"\" class=\"wp-image-88\"\/><figcaption>Figure 3: Finding the tunnel menu<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">And selecting this the right pane of the Putty GUI will display:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"325\" height=\"287\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/05\/Blank-Tunnel-Menu.png\" alt=\"\" class=\"wp-image-89\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/05\/Blank-Tunnel-Menu.png 325w, http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/05\/Blank-Tunnel-Menu-300x265.png 300w\" sizes=\"auto, (max-width: 325px) 100vw, 325px\" \/><figcaption>Figure 4: Blank tunnel menu.<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">This is going to be a remote tunnel so select the &#8216;Remote&#8217; radio button and choose a random high port, I\u2019ve chosen my favourite number: 13389.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"> The destination ip address is going to be that of the Windows server we\u2019re actually working on as we\u2019re telling the tunnel where to come back to. Also if we add  &#8216;:3389&#8217; on the end of this it will tell the returning connecton  to use tcp  3389 which is the standard port for remote desktop. So putting that altogether, you should see what\u2019s show in Figure 4<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"296\" height=\"124\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/05\/Populated-Tunnel-Menu.png\" alt=\"\" class=\"wp-image-90\"\/><figcaption>Figure 5: Defning the tunnel<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Now, if  clicking the \u2018Add\u2019 button; the following tunnel should appear.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"317\" height=\"269\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/05\/Putty-Tunnel.png\" alt=\"\" class=\"wp-image-91\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/05\/Putty-Tunnel.png 317w, http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/05\/Putty-Tunnel-300x255.png 300w\" sizes=\"auto, (max-width: 317px) 100vw, 317px\" \/><figcaption>Figure 6: The tunnel definition in lace<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">What we\u2019ve asked Putty to do is to connect to 10.20.10.60 create a listener on that very same host on port 13389, the mouth of the tunnel if you like, which pops out on 10.20.10.30 on port 3389 where there should be a handy listener for RDP.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Windows  reaches out.<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now, having defined our tunnel, if we go back to the main menu in Figure 2 and press &#8216;open&#8217; we will connect to the Linux host and login as per usual.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"502\" height=\"123\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/05\/Logging-into-Linux.png\" alt=\"\" class=\"wp-image-92\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/05\/Logging-into-Linux.png 502w, http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/05\/Logging-into-Linux-300x74.png 300w\" sizes=\"auto, (max-width: 502px) 100vw, 502px\" \/><figcaption>Figure 7: Connecting to Linux<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Are you listening?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">And, we ask ourselves, has the magic portal been created on port 13989? Taking a look (see Figure 8) it looks like it has.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"635\" height=\"121\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/05\/Tunnel-13389.png\" alt=\"\" class=\"wp-image-94\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/05\/Tunnel-13389.png 635w, http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/05\/Tunnel-13389-300x57.png 300w\" sizes=\"auto, (max-width: 635px) 100vw, 635px\" \/><figcaption>Figure 8: The mouth of the tunnel.<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Now, using the Linux RDP client Remmina,  we are going to connect to our loopback using port 13389 and go down the tunnel to our Windows host. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thus, if we had a simple port filtering device disallowing us to connect over RDP we would have defeated it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I hadn\u2019t used Remmina, the Linux RDP client, before but it was very user friendly and where the server ip address was to be specified I put in the loopback address with the port 13389 and the username and password of the Windows hosst.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"602\" height=\"108\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/05\/image-5.png\" alt=\"\" class=\"wp-image-95\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/05\/image-5.png 602w, http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/05\/image-5-300x54.png 300w\" sizes=\"auto, (max-width: 602px) 100vw, 602px\" \/><figcaption>Figure 9<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">And this connected just fine. I captured this happy moment in a somewhat half-arsed fashion in Figure 10 &#8211; the RDP session is  the background window. I did think of getting a better one but I have since deleted all the VMs used in the lab but I think you can make out the Windows &#8216;Recycle Bin&#8217; &#8211; in the Remmina window .<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"390\" height=\"347\" src=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/05\/RDP-connection.png\" alt=\"\" class=\"wp-image-97\" srcset=\"http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/05\/RDP-connection.png 390w, http:\/\/18.135.13.153\/wp-content\/uploads\/2020\/05\/RDP-connection-300x267.png 300w\" sizes=\"auto, (max-width: 390px) 100vw, 390px\" \/><figcaption>Figure 10<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Again nothing earth-shattering here, a simple exercise building on the previous post. What do we want to do? This time we want to build a tunnel from a Windows host to a Linux one using the ssh utility Putty and then connect back to the Windows host down the tunnel using a remote desktop program. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"class_list":["post-85","post","type-post","status-publish","format-standard","hentry","category-security"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/18.135.13.153\/index.php?rest_route=\/wp\/v2\/posts\/85","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/18.135.13.153\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/18.135.13.153\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/18.135.13.153\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/18.135.13.153\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=85"}],"version-history":[{"count":0,"href":"http:\/\/18.135.13.153\/index.php?rest_route=\/wp\/v2\/posts\/85\/revisions"}],"wp:attachment":[{"href":"http:\/\/18.135.13.153\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=85"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/18.135.13.153\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=85"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/18.135.13.153\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=85"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}