I want to practice by scripting a reverse ssh tunnel in python

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • somas1
    New Member
    • Jan 2007
    • 3

    #1

    I want to practice by scripting a reverse ssh tunnel in python

    I've checked out quite a few web tutorials on Python and have bought a few books. I've got a lot of the basics down now but feel very limited because I've got difficulties figuring out how to do things without seeing how a more experienced programmer would get started solving a problem.

    I often have to remotely ssh into a friend's ibook but his ISP blocks ssh. This means I've got to talk him through setting up a reverse ssh tunnel from his ibook to mine and this often frustrates both of us.

    I'd like to write a Python script that will setup this tunnel when he double clicks it. What do I use to start ssh in a script? Do I use popen? the subprocess module? Trying to figure out how to start is very frustrating and I'd appreciate pointers.

    BTW, I'm running OS X and Linux and Python 2.3, 2.4 and 2.5
  • ghostdog74
    Recognized Expert Contributor
    • Apr 2006
    • 511

    #2
    Originally posted by somas1
    I've checked out quite a few web tutorials on Python and have bought a few books. I've got a lot of the basics down now but feel very limited because I've got difficulties figuring out how to do things without seeing how a more experienced programmer would get started solving a problem.

    I often have to remotely ssh into a friend's ibook but his ISP blocks ssh. This means I've got to talk him through setting up a reverse ssh tunnel from his ibook to mine and this often frustrates both of us.

    I'd like to write a Python script that will setup this tunnel when he double clicks it. What do I use to start ssh in a script? Do I use popen? the subprocess module? Trying to figure out how to start is very frustrating and I'd appreciate pointers.

    BTW, I'm running OS X and Linux and Python 2.3, 2.4 and 2.5
    i assume you are using ssh command on you linux machines. usually how do you connect? its something like this right?
    Code:
    $ ssh -nNT -R 1000:local:1000 remote
    you can either put this command in a shell script (since you are working with linux) or you can do a python script like you have said. but use os.popen() or os.system() or subprocess modules or this.

    Comment

    Working...