SSH jumping over socks(4/5) proxy chain. Host -> socks proxy -> socks proxy -> destination
Solution 1
With:
socat tcp-listen:12345,reuseaddr,fork,bind=127.1 socks:218.62.97.105:11.11.11.11:3128,socksport=1080
you will have a socat waiting for TCP connections on port 12345 on the loopback interface, and forward them to 11.11.11.11:3128 by way of the socks server on 218.62.97.105:1080
You can then use that to connect to D:
ssh -o ProxyCommand='socat - socks:127.1:%h:%p,socksport=12345' -p 8080 55.55.55.55
(untested)
Solution 2
I use tsocks for this purpose. It's a wrapper that catches all connects and forwards them according to your tsocks.conf file. For instance:
server = 127.0.0.1
server_type = 5
server_port = 1338
Where as you already have a ssh-proxy set on localhost port 1338. Using this method, you can nest connections since the next ssh session running in the tsocks wrapper will behave as if on the other end of the ssh connection.
Not necessarily better than using socat, but I find it easier to keep control of.
Related videos on Youtube
Philipp M
Updated on September 18, 2022Comments
-
Philipp M over 1 year
I'm trying to implement dependable selects with jQuery. Let's say I have this scenario:
The user can choose several items, every select is for one item. The items are unique - the user can only choose an item once. If the user chooses one item in the first select it should be available in the others and vice versa. At the beginning only one select is visible (the user has to choose one item at least). If the user wants to add another one, s/he can click on a link which displays a new select.
I came up with the following code, but it's not working correct because the selects will overridden from the clone. I'm stuck here and I already tried another approach where I didn't use a clone. Didn't work either. Any suggestions what I can do?
Edit: Seems like I finally found the solution.. I changed the code appropriately here.
<style type="text/css"> select { width: 60%; } </style> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script> <script type="text/javascript"> $(function() { var clone = $('#ParentSlug').clone().removeAttr('id'); $('#categories-selects select').change(function() { console.log("change of id: " + $(this).attr('id') ); $('#categories-selects select').each(function() { $this = $(this); var id = $this.attr('id'); var value = $this.val(); //console.log(id); $this.html(clone.html()); $this.attr('id', id); $this.val(value); $this.siblings(':visible').each(function() { $this.find("option[value='" + $(this).val() + "']").remove(); }); }); }); $('.add-select').click(function() { $('#categories-selects select:hidden:first').show().change(); if ($("#categories-selects select:visible").length > 1) $(".remove-select").show(); if ($("#categories-selects select:hidden").length == 0) $(".add-select").hide(); }); $('.remove-select').click(function() { $("#categories-selects select:visible:last").hide().change(); if ($("#categories-selects select:visible").length == 1) $(this).hide(); if ($("#categories-selects select:hidden").length > 0) $(".add-select").show(); }); }); </script>
<select id="ParentSlug"> <optgroup label="Customer Relationship Management Help"> <option value="notes-files">Notes & Files</option> <option value="permissions">User & Permissions</option> </optgroup> <optgroup label="Service Management Help"> <option value="contacts-tagging">Contacts & Tagging</option> <option value="import-export">Import & Export</option> <option value="orders">Orders</option> <option value="scheduling">Scheduling</option> <option value="service-cases-service">Service Cases & Service</option> <option value="tasks">Tasks</option> </optgroup> </select> <select id="category-1" style="display: none;"> <optgroup label="Customer Relationship Management Help"> <option value="notes-files">Notes & Files</option> <option value="permissions">User & Permissions</option> </optgroup> <optgroup label="Service Management Help"><option value="contacts-tagging">Contacts & Tagging</option> <option value="import-export">Import & Export</option> <option value="orders">Orders</option> <option value="scheduling">Scheduling</option> <option value="service-cases-service">Service Cases & Service</option> <option value="tasks">Tasks</option> </optgroup> </select> <select id="category-2" style="display: none;"> <optgroup label="Customer Relationship Management Help"> <option value="notes-files">Notes & Files</option> <option value="permissions">User & Permissions</option> </optgroup> <optgroup label="Service Management Help"> <option value="contacts-tagging">Contacts & Tagging</option> <option value="import-export">Import & Export</option> <option value="orders">Orders</option> <option value="scheduling">Scheduling</option> <option value="service-cases-service">Service Cases & Service</option> <option value="tasks">Tasks</option> </optgroup> </select> <select id="category-3" style="display: none;"> <optgroup label="Customer Relationship Management Help"> <option value="notes-files">Notes & Files</option> <option value="permissions">User & Permissions</option> </optgroup> <optgroup label="Service Management Help"><option value="contacts-tagging">Contacts & Tagging</option> <option value="import-export">Import & Export</option> <option value="orders">Orders</option> <option value="scheduling">Scheduling</option> <option value="service-cases-service">Service Cases & Service</option> <option value="tasks">Tasks</option> </optgroup> </select> <select id="category-4" style="display: none;"> <optgroup label="Customer Relationship Management Help"> <option value="notes-files">Notes & Files</option> <option value="permissions">User & Permissions</option> </optgroup> <optgroup label="Service Management Help"> <option value="contacts-tagging">Contacts & Tagging</option> <option value="import-export">Import & Export</option> <option value="orders">Orders</option> <option value="scheduling">Scheduling</option> <option value="service-cases-service">Service Cases & Service</option> <option value="tasks">Tasks</option> </optgroup> </select> <select id="category-5" style="display: none;"> <optgroup label="Customer Relationship Management Help"> <option value="notes-files">Notes & Files</option> <option value="permissions">User & Permissions</option> </optgroup> <optgroup label="Service Management Help"> <option value="contacts-tagging">Contacts & Tagging</option> <option value="import-export">Import & Export</option> <option value="orders">Orders</option> <option value="scheduling">Scheduling</option> <option value="service-cases-service">Service Cases & Service</option> <option value="tasks">Tasks</option> </optgroup> </select> <select id="category-6" style="display: none;"> <optgroup label="Customer Relationship Management Help"> <option value="notes-files">Notes & Files</option> <option value="permissions">User & Permissions</option> </optgroup> <optgroup label="Service Management Help"> <option value="contacts-tagging">Contacts & Tagging</option> <option value="import-export">Import & Export</option> <option value="orders">Orders</option> <option value="scheduling">Scheduling</option> <option value="service-cases-service">Service Cases & Service</option> <option value="tasks">Tasks</option> </optgroup> </select> <select id="category-7" style="display: none;"> <optgroup label="Customer Relationship Management Help"> <option value="notes-files">Notes & Files</option> <option value="permissions">User & Permissions</option> </optgroup> <optgroup label="Service Management Help"> <option value="contacts-tagging">Contacts & Tagging</option> <option value="import-export">Import & Export</option> <option value="orders">Orders</option> <option value="scheduling">Scheduling</option> <option value="service-cases-service">Service Cases & Service</option> <option value="tasks">Tasks</option> </optgroup> </select> </span> <a class="add-select" href="#"><img src="#" alt="[+]" /></a> <a class="remove-select" href="#" style="display: none;"><img src="#" alt="[-]" /></a>
-
Philipp M over 13 yearsI'm afraid this is not what I need. It should always be all values minus the already selected ones be available in my case.
-
mnmnc over 11 yearsFirstly I used the command
socat tcp-listen:22222,reuseaddr,fork,bind=127.1 socks:218.62.97.105:193.107.144.23:80,socksport=1080
and i checked that both those proxies are working with the command you have given me in my previous question. However when i supply the second command :ssh -o ProxyCommand='socat - socks:127.1:%h:%p,socksport=22222' -p 21 xxx.dyndns.org
nothing is really happening for a while and then the error message:EOF during read of socks reply, peer might not be a socks4 server ssh_exchange_identification: Connection closed by remote host
-
mnmnc over 11 yearsthe xxx.dyndns.org is my computer - Machine A but its external IP address and listening on port 21. I'm sure it works fine as i used it with
ssh -o ProxyCommand='socat - socks:218.62.97.105:xxx.dyndns.org:21,socksport=1080'
and it gave me the sshd prompt. -
Stéphane Chazelas over 11 yearsTry and add a few -d options to the
socat
s. -
mnmnc over 11 yearsI added the debug in my question. I feel like the fault is in the line
2012/10/02 20:52:21 socat[17091] E socks: ident refused by client
which might be caused by my username being passed in the line2012/10/02 20:52:10 socat[17091] I sending socks4 request VN=4 DC=1 DSTPORT=1080 DSTIP=89.223.109.20 USERID=mnmnc
-
Stéphane Chazelas over 11 yearsYes, I suspect those SOCKS proxies have limitations on what you can connect to through them. As when I try the solution above with two socks proxies of mine (
ssh -D
ones) it works fine.