[Tutor] ssh socks proxy

kushal.kumaran+python at gmail.com kushal.kumaran+python at gmail.com
Thu May 17 04:59:16 CEST 2012

Adam Gold <adamgold at lavabit.com> wrote:

>I'm trying to write a 'simple' script that will set up a socks proxy
>over ssh and maintain the connection until manually terminated.   It's
>not possible to use key-based authentication so a password will need to
>be supplied.  Also, note, the user is presented with a list of servers
>to choose from at the beginning.  The actual ssh command is: 'ssh -vNCD
>23333 user at host'.
>I've been tinkering with both pexpect and paramiko but fear I'm making
>a mountain out of a mole hill.  I'm aware both have example scripts for
>ssh forwarding but, to be honest, they are both too complicated (aka I
>don't know how to customise them).  Here is one script I've attempted
>to get working and the associated error listing:
>http://pastebin.com/jj8Fgvwm - script
>http://pastebin.com/jRA8zpzi - error
>Could anyone help me either correct the script I've started or suggest
>an ockham's-razor-adherent alternative!  Many thanks.

The error message indicates that there hostname HOST could not be resolved. You need to replace that with the value of the variable HOST.

COMMAND = "ssh -vNDR 23333 {}@{}".format(USER, HOST)

I'm curious to know why you can't use keys. They make things much simpler.


More information about the Tutor mailing list