Thursday, 28 September 2017

SSH over proxy or over multiple hosts

Well, sometimes an evil sysadmin won't let us to live in peace and close all the ports that you need (of course, except the ssh).

Presuming that you already have a host with ssh and Internet access (host1 in the following example) you can use it as a "jump" platform or as SOCKS proxy server to reach a target host (host2 here).

+-----------+<--port 22-->+---------+<--port 2222-->+----------+
|   mybox   |-------------|  host1  |---------------|   host2  |
+-----------+             +---------+               +----------+
localhost:8080            "jump" host                  target


Using as proxy server:
(in this example we have two steps, but you can join those steps in one. Hint:  use && as in command1 && command2 and -f ssh parameter).

mybox:~$ ssh -D 8080 -N -p 22 user@host1
user@host1's password:

Type the password and let this terminal open and open another one.

mybox:~$ ssh -X -p 2222 user2@host2 -o ProxyCommand="/usr/bin/connect -5 -S localhost:8080 %h %p"

Jumping over ssh:
mybox:~$ ssh -t -X -p 22 user@host1 ssh -X -p 2222 user@host2

You may ask yourself "Why not using the second example all the time because is simple and more convenient???". 
Well, the simple answer is that you can not use X11 forwarding (-X parameter) if the host1 had not implemented the X11 forwarding rule in the sshd_config. So, no X11 forwarding in this case.
The first example (proxy), because is a SOCKS tunnel, have no importance if the host1 have or not have the X11 forwarding rule active. As a tunnel, it pass the packets between the two ends of it.

18 comments:

  1. A Complete Guide to a managed security service provider near me

    The demand for managed security is continuously growing. It seems that many small and medium-sized businesses love this particular business model, and there are a few good reasons why.

    Business owners expect specific benefits when they choose a managed service model to make their job easier. But, what does it mean to receive managed security services? What do manage service providers do for you and your business?

    In this article we’re going to explain everything you need to know about managed IT security, so let’s start by explaining the meaning of this term.

    ReplyDelete
    Replies
    1. HTS provides you the best advanced excel training in Delhi. We surely have so much for you to make you best in data analysis.We have highly skillful trainers for Advance Excel courses. The Module of High Technologies Solutions is so simple and compressive that includes complete knowledge of Excel beginning to Advance.contact here +91-9311002620
      visit https://www.htsindia.com/Courses/business-analytics/adv-excel-training-course

      Delete
  2. I really enjoyed reading your blog. I really appreciate your information which you shared with us. If anyone who want to create his/her carrier in Linux. Get a free demo call on 9311002620 or visit https://htsindia.com/Courses/modular-courses/linux-training-institute

    ReplyDelete
  3. Thanks for posting these kinds of post its very helpful and very good content a really appreciable post apart from that if anyone looking for C++ training institute in delhi so contact here +91-9311002620 visit https://www.htsindia.com/Courses/modular-courses/c-plus-plus-training-course

    ReplyDelete
  4. Very nice post thank you for sharing this post its very knowledgeable and very helpful i hope that you will continue to post these kinds of contents in future apart from that if anyone looking for AutoCAD institute in delhi so check out this Contact Here-+91-9311002620 Or Visit Website- https://www.htsindia.com/AutoCAD-training-courses

    ReplyDelete
  5. HTS provides you the best advanced excel training in Delhi. We surely have so much for you to make you best in data analysis.We have highly skillful trainers for Advance Excel courses. The Module of High Technologies Solutions is so simple and compressive that includes complete knowledge of Excel beginning to Advance.contact here +91-9311002620
    visit https://www.htsindia.com/Courses/business-analytics/adv-excel-training-course

    ReplyDelete
  6. Informative article. I generally want quality content and I found that in your post. The information you have shared about taxi service is beneficial and significant for us. Keep sharing these kinds of articles here. Great blog, thanks for sharing. cyber security companies in India

    ReplyDelete
  7. Great blog ! I am impressed with suggestions of author. Sophos antivirus Brisbane

    ReplyDelete
  8. Thank you for sharing your valuable knowledge and insights. Great job for publishing such a nice article. Your article isn’t only useful but it is additionally really informative. Keep sharing such enlightening articles. Best Cyber security companies

    ReplyDelete
  9. Very nice post thank you for sharing this post its very knowledgeable and very helpful i hope that you will continue to post these kinds of contents in future apart from that if anyone looking for Advance Excel institute in delhi so Contact Here-+91-9311002620 Or Visit Website- https://www.htsindia.com/Courses/business-analytics/adv-excel-training-course

    ReplyDelete
  10. Thank you for sharing this post its very knowledgeable i hope that you will continue to post these kinds of contents in future apart from that if anyone looking for Advance Excel institute in delhi so Contact Here-+91-9311002620 Or Visit Website- https://www.htsindia.com/Courses/business-analytics/adv-excel-training-course

    ReplyDelete
  11. Ensuring the safety of websites or web applications is essential to prevent any sort of attacks (threats) and unauthorized access. As cyber security company in India, I found this information valuable. Glad to read this, great blog. Network vulnerability assessment services

    ReplyDelete
  12. Your post is very good thanks for sharing these kind of post apart form that if anyone look for Python training institute in Delhi Contact Here-+91-9311002620 Or Visit Website- https://www.htsindia.com/Courses/python/python-training-institute-in-delhi

    ReplyDelete
  13. Your post is really good thanks for sharing these kind of post but if anyone looking for Best Consulting Firm for Fake Experience Certificate Providers in chennai, India with Complete Documents So Dreamsoft Consultancy is the Best Place.Further Details Here- 9599119376 or VisitWebsite- https://experiencecertificates.com/experience-certificate-provider-in-chennai.html

    ReplyDelete
  14. this is very nice blog Hire a reliable Affordable Cleaning Company Bangalore because professional cleaners use different tools which help them to accomplish the cleaning more efficiently. If you have got an enormous home, you must choose us because we've got a team of experienced experts. This can be important, especially if you're getting to pay by the hour because one person cleaning goes to cost you way more than a team of cleaners.

    ReplyDelete