Scenario: Create socks5 proxy over ssh
This would enable a heavily protected host to access internet for updating packages, executing “pip install” (how to) or something like that.
Dependence:
Example 1

## filename: example1.spy
from socksproxy import ThreadingSocksProxy
import threading, traceback
remote_port = 8080
with $.connect('user@host-1',password='123456') as c1:
    with $.connect('user2@host-2',password='123456') as c2:
        try:
            transport = c2.client.get_transport()
            ThreadingSocksProxy(transport,remote_port).start().join()
            ## To require credentials for client, do it like blow:
            #ThreadingSocksProxy(transport,remote_port,'username','password').start().join()
        except KeyboardInterrupt:
            pass
        except:
            traceback.print_exc()
          
Execution & Tests
## Execution on localhost
sshscript example1.spy
## Tests on host-2
curl -k -x socks5h://localhost:8080 https://www.google.com
## When requires credentials
curl -k -U username:password -x socks5h://localhost:8080 https://www.google.com