-
-
Save dstufft/9dc9978dc0af77e82f0c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
import sys | |
from twisted.internet import defer | |
from twisted.internet.endpoints import TCP4ClientEndpoint, connectProtocol | |
from twisted.internet.task import react | |
from twisted.conch.ssh.transport import SSHClientTransport | |
from twisted.python import log | |
log.startLogging(sys.stdout, setStdout=False) | |
class ForgeSSHClientTransport(SSHClientTransport): | |
# def verifyHostKey(self, hostKey, fingerprint): | |
# print("WAT") | |
# return defer.succeed(True) | |
def connectionSecure(self): | |
print("Testing") | |
def main(reactor, hostname, port): | |
port = int(port) | |
sshClient = TCP4ClientEndpoint(reactor, hostname, port) | |
d = connectProtocol(sshClient, ForgeSSHClientTransport()) | |
return d | |
if __name__ == "__main__": | |
react(main, sys.argv[1:]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
import sys | |
from twisted.internet import defer | |
from twisted.internet.endpoints import TCP4ClientEndpoint, connectProtocol | |
from twisted.internet.task import react | |
from twisted.conch.ssh.transport import SSHClientTransport | |
from twisted.python import log | |
log.startLogging(sys.stdout, setStdout=False) | |
class ForgeSSHClientTransport(SSHClientTransport): | |
def __init__(self): | |
self.connectionReady = defer.Deferred( | |
lambda d: self.transport.abortConnection() | |
) | |
# Clear the reference to that deferred to help the garbage collector | |
# and to signal to other parts of this implementation (in particular | |
# connectionLost) that it has already been fired and does not need to | |
# be fired again. | |
def readyFired(result): | |
self.connectionReady = None | |
return result | |
self.connectionReady.addBoth(readyFired) | |
# def verifyHostKey(self, hostKey, fingerprint): | |
# print("WAT") | |
# return defer.succeed(True) | |
def connectionSecure(self): | |
print("Testing") | |
def main(reactor, hostname, port): | |
port = int(port) | |
sshClient = TCP4ClientEndpoint(reactor, hostname, port) | |
d = connectProtocol(sshClient, ForgeSSHClientTransport()) | |
d.addCallback(lambda protocol: protocol.connectionReady) | |
return d | |
if __name__ == "__main__": | |
react(main, sys.argv[1:]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment