summaryrefslogblamecommitdiffstats
path: root/notFinishedCode/SSHTunnelClass.py
blob: 39f05a46893d20996d0f917c5731ae1bf2cc4f4c (plain) (tree)





















                                                                                                                                                                                   
import subprocess 
import string

class SSHTunneling:
	
	def __init__(self, localPort, remotePort, remoteServer, username, password):
		self.lPort = localport
		self.rPort = remotePort
		self.rServer = remoteServer

		self.usern = username
		self.passw = password

		self.__tunnelStarted = 0

	def startTunneling(self):
		if self.__tunnelStarted == 0:
			command = str(self.lPort) + ':' + self.rServer + ':' str(self.rPort) 
			uad = self.usern + '@' + self.rServer
			result = subprocess.Popen(['ssh', '-f', '-g', '-A', '-X', '-N', '-L', command, uad], stdout = subprocess.PIPE, stderr = subprocces.STDOUT).communicate()[0]

	def closeTunneling(self):